javascript - Contact Form - AJAX being ignored -


Hello friends, I can not make a JS field, I can see a problem in this AJAX form, I used this code before And it is this work like ASF, the website is not reading Ajax code and I've spent hours working on it.

AJX:

  & lt ; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ ("# submit_button"). Click (function (event) {event.preventDefault (); // Cancel name of name name var name = $ ("# name"). Val (); Var company = $ ("# company"). Val (); var Comment = $ ("# comments"). Val (); if (name! = '' & Amp; Company! = '' & Amp; amp; comments: = '') {$ .ajax ({url: "review.php", type: "post", data: {name: name, company: company, comments: comments} success: work (data ) You can say that the message sent to the user should show that the form is successful $ ('# Contact Form'). CSS ({'Opacity': 0.4}); $ ("# Success Message"). $; "$ (" # Danger "). Hide ();} });} And {$ ("# message of danger"). How ();}}); // Click ()}); // Ready () & lt; / Script & gt;  

HTML:

  & lt; Div id = "successmessage" style = "display: none;" Class = "alert-success" role = "alert" & gt; & Lt; Strong> Thanks, your review has been received, we will upload soon! & Lt; / Strong> & Lt; / Div & gt; & Lt; Div id = "dangermessage" style = "display: none;" Class = "warning-danger" role = "alert" & gt; & Lt; Strong & gt; Something went wrong, all the fields are filled properly? & Lt; / Strong> & Lt; / Div & gt; & Lt; H4 & gt; Want to add a review? & Lt; / H4 & gt; & Lt; Form id = "review" name = "review" method = "post" action = "review.php" class = "reviewForm" & gt; & Lt; Input class = "inputLeft" type = "text" id = "name" name = "name" placeholder = "* first and second name" & gt; & Lt; Input class = "inputRight" type = "text" id = "company" name = "company" placeholder = "* company" & gt; & Lt; Br / & gt; & Lt; Textarea name = "comments" id = "comments" placeholder = "comments:" & gt; & Lt; / Textarea & gt; & Lt; Br / & gt; & Lt; Button id = "submit_button" class = "sendBtn" & gt; Send & lt; / Button & gt; & Lt; / Form & gt;  

PHP:

  & lt ;? Php if (isset ($ _ POST ['name'])) {$ name = $ _POST ['name']; // Essential $ Company = $ _POST ['Company']; // comment not required $ = $ _POST ['comment']; // essential $ email_to = "test@live.co.uk"; $ Email_subject = $ name "submit review"; Function clean_string ($ string) {$ bad = array ("content-type", "bcc:", "to:", "cc:", "href"); Return str_replace ($ Bad, "", $ string); } $ Email_message = "First name:" .clean_string ($ name). "\ N"; $ Email_message = "Company:" .clean_string ($ Company). "\ N"; $ Email_message = "Comments:" .clean_string ($ Comments). "\ N"; // Create Email Header $ header = 'From:'. $ Name $ Company "\ R \ n". 'Answer-To:'. $ Name $ Company "\ R \ n". 'X-Mailer: PHP /' phpversion (); @ Email ($ email_to, $ email_subject, $ email_message, $ header); // @mail ($ email_ass, $ email_sube, $ email_message, $ header); ? & Gt; & Lt ;! - Include your own success here in HTML - & gt; & Lt ;! Thank you for contacting us. We will contact you very soon. Php}? & Gt;  

I have been working on php form and trying to send mails, but AJX is not working, after some bad I was able to display a message of danger but now It is not even that.

To do this, send.

In addition I have used this snippet code on another website and it is working perfectly.

Thank you guys

A comma after you forgot the data:

  data: {name: name, company: company, comments: comments}, success: work (data) { 

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -