[Rails] Re: Headache with Ajax in Rails using jQuery
Thanks a lot everyone! Masta, I did as you said:
...
var values = $("#contactForm").serialize();
$.ajax({
url: "/main/contact",
type: "post",
data: values,
success: function(data, textStatus, xhr){
alert("textStatus: " + textStatus + "; xhr: " + xhr + "; data: " +
data);
$("#result").html(data.message);
}
});
Here's what I got based on the alert() above:
+ textStatus: success
+ xhr: [object XHMHttpRequest]
+ data: returned the source code of the current (contact) page (a
shock!) instead of the result in json that I expected.
Two possible issues: (1) I'm wondering if the ajax call made to the
server side to the contact action of the main controller, (2) whether
the result was rendered to json correctly by rails. Thanks again
everyone.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9b6965181d7d036d486527f66c0cc672%40ruby-forum.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home