xml_http_request "/store/add_to_cart" , :id => ruby_book.id
經過查詢 Rais2 的 API 文件之後,發現原來是 xml_http_request 的參數已經做了變更,詳細的參數與說明如下所示(節錄於 Rails2 API 文件)
xml_http_request(request_method, path, parameters = nil, headers = nil)
Performs an XMLHttpRequest request with the given parameters, mirroring a request from the Prototype library.
The request_method is :get, :post, :put, :delete or :head; the parameters are nil, a hash, or a url-encoded or multipart string; the headers are a hash. Keys are automatically upcased and prefixed with ‘HTTP_’ if not already.
This method is also aliased as xhr
xml_http_request :post, "/store/add_to_cart" , :id => ruby_book.id
沒有留言:
張貼留言