php - no response ajax request -
I am trying to make a simple login with AJAX. My problem is that I have not received any response from my request. When I
myurl.com/login.php is_ajax = 1 & amp; I try to use username = test and password = test
I get a successful message back. ($ ("$ User name"). (Function () {$ ("# submit") (function () {var form_data = {usernm: $ ("# username"). Val (), passwd: $ ("# Password") Val (), is_ajax: 1}; $ .ajax ({type: "POST", url: "myurl.php", data: form_data, succes: function (feedback) {if (response == 'succes') {window.location = "myurl.html";} and {warnings ("wrong user name password combination")}}}) return false;})}};
my php:
$ is_ajax = $ _REQUEST ['is_ajax']; If (isset ($ is_ajax) & $ is_ajax) {$ uName = $ _REQUEST [' Username ']; $ PWord = $ _REQUEST [' password ']; if ($ uName ==' test '& amp; $ pWord ==' Test ') {echo' succes';} Else {echo 'false';} << Code>
Change succes
with $ .ajax ({type: "post", url: "myurl.php", data: form_data, success: function (feedback) { If (feedback == 'success') {Window.location = "myurl.html";} and {warnings ("wrong user name password combination");}}});
Also change the data attribute name
var form_data = {username: $ ("#username"). Val (), Password: $ ("#password"). Val (), is_ajax: 1};
Comments
Post a Comment