php - Ajax form not being submitted -


i attempting send simple login form jquery modal form.

$(  "#dialog-form"  ).dialog({     var url = "../scripts/sign_up.php";      $.ajax({         type: "post",         url: url,         data: $("#dialog-form").serialize(),         success: function(data){             alert("it works")         }     }); }); 

this first real shot @ trying ajax , having issues getting success method go through. have checked script in right place , dialog_form has right id.

am sending information incorrectly? there way troubleshoot ajax requests?

right trying info go through and, question, removed other code form.

first, might reccommend adding error function ajax request - may error handling:

error: function (jqxhr, textstatus, errorthrown) {     alert(textstatus);     alert(errorthrown); } 

second, how sending data script ajax request? if you're not echoing data script, request not going know script ran sucessfully.

therefore, may want add following ajax call:

datatype: "json", 

and return data php script so:

$data = array("success"=> true); echo json_encode($data); exit; 

in full (using script):

$(  "#dialog-form"  ).dialog({     var url = "../scripts/sign_up.php";     $.ajax({         type: "post",         url: url,         datatype: "json",         data: $("#dialog-form").serialize(),         success: function(data) {             if (data.success) {                 alert("it works")             }             else {                alert("it failed, no server error!");             }         }         error: function (jqxhr, textstatus, errorthrown) {             alert("server error");             alert(textstatus);             alert(errorthrown);         }     }); }); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -