OK, I'm very close to this, but I need to help a bit on the hunch. I am trying to submit a form in a Rail app, which sends an email, and then executes some code of success. When I hit Enter in my form, AJAX is working because I'm receiving an email, though, the success code is not running (and there is no error for that too). I tried to 'complete:' but she was not working, so I doubt that this default behavior can be a problem with something? idea?
Ajax:
// Submit an email form to the AJAX function without the refreshing page $ ("# contact_me"). Submit (function () {var DataSet = $ (this) .serialize (); $ .ajax ({type: "POST", url: $ (this) .attr ("verb"), data: dataset, success: Function () (Warning ("Sent!);}, Error: Action () {Warning (" Something went wrong! "}}}); Return;}) And the rail operations that call it:
def email_me name = params [: name] email = params [: email] content = params [: text] ContactMailer.first_contact (name, email, content Deliver head: ok end In addition, the form also
& lt;% = form_tag ({controller: "main", verb: Email_me "}, id:" contact_me ", and ("Name")%> <% = text_field_tag (: Name)%> p> <% = label_tag (: Email, " Email ")%> gt; & lt;% = email_field (: user, email)%> & lt; / p & gt; & lt; / div & gt; & lt; div & gt; & lt; P & gt; & lt;% = label_tag (: text, "what's in your mind?")% & Gt; & Lt; / P & gt; & Lt;% = text_area_tag (: lesson)% & gt; & Lt; / Div & gt; & Lt;% = submit_tag ("Hello!")% & Gt; & Lt;% end% & gt;
These are really small things that eventually create the biggest problems. I forgot to wrap the entire function in the function () {.} Go figure, thanks for all the great works now.
$ (function () {$ ("# contact_me"). Submit (function () {var dataSet = $ (this). Serialize (); $ Ajax ({type: " Post ", url: $ (this) .attr (" verb "), data: dataset, complete: function () {warning (" sent! ");}, Error: work () {alert (" something is wrong Gone! ");}}); Return;});})
No comments:
Post a Comment