I am not sure where I should post this since this seems to be an "interdisciplinary" problem
I am having trouble communicating between my javascript and my Rails app.
Here's the snipped of code from my controller - - - def poll p params puts "Got here:" # debugger @some_object = 12345 respond_to do |format| format.json { render :layout => false, :json => @some_object } end end - - -
I see - - - {"comment"=>"ch", "_method"=>"PUT", "action"=>"poll", "controller"=>"reviews", "_"=>"1275680223825"} Got here: - - - in the Webrick console log
Here's the relevant javascript: - - - - pollWithAjax = function() { $.ajax( { // Define AJAX properties. type: "GET", url: "/poll", dataType: "script", data: { _method: 'PUT', "comment": 'ch' }, timeout: (10 * 1000), beforeSend: function(xhr) {xhr.setRequestHeader("Accept", "application/json")},
// Define the succss method. success: function(){ alert('pollWithAjax Success') },
// Define the error method. error: function( objAJAXRequest, strError, errorThrown ){ alert("pollWithAjax Error! Type: " + strError); } } ); }; - - - -
The "error:" function returns with the value of strError being "error".
This is what FireBug says my headers look like - - - Response Headersview source Request Headersview source Host localhost:3000 User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729) Accept application/json Accept-Language en-us,en;q=0.5 Accept-Encoding gzip,deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive 115 Connection keep-alive X-Requested-With XMLHttpRequest Referer http://localhost:3000/products/1 Cookie _store_session=BAh7CDoPc2Vzc2lvbl9pZCIlZDZhNDMyMjI2OTNhMTAzNTQxZjVmNTA5MDIwOTc1MDUiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA6EF9jc3JmX3Rva2VuIjFnREJwbW9Oam02NFArWWxla1dXUE1OMmk2eU9EUk9lWnhDMDF4WHA0QUtFPQ%3D%3D--582cb4d8997a9876030fa55e15d37e12177b02db - - -
When I click on the response tab in Firebug, I see nothing.
Am I setting up the headers incorrectly?