Pengcoder Posted February 13, 2020 Share Posted February 13, 2020 Please help with Ajax call, when clicking login button nothing happens when it should go to mainpageloggedin.php deano Quote Link to comment Share on other sites More sharing options...
Pengcoder Posted February 13, 2020 Author Share Posted February 13, 2020 $("#loginform").submit(function(event){ //prevent default php processing event.preventDefault(); //collect user inputs var datatopost = $(this).serializeArray(); console.log(datatopost); //send them to login.php using AJAX $.ajax({ url: 'login.php', type: "POST", data: datatopost, success: function(data){ if(data == "success"){ window.location('mainpageloggedin.php'); }else{ $("#loginmessage").html(data); } }, error:function(){ $("#loginmessage").html('<div class="alert alert-danger">There was an error with the Ajax Call. Please try again later1.</div>'); } }); }); Quote Link to comment Share on other sites More sharing options...
Barand Posted February 13, 2020 Share Posted February 13, 2020 Have you checked the calls' headers and responses in the network tab of your browser's developer tools? Quote Link to comment Share on other sites More sharing options...
Pengcoder Posted February 14, 2020 Author Share Posted February 14, 2020 Hi Barand thankyou new to PHP but code above does look right? Quote Link to comment Share on other sites More sharing options...
Barand Posted February 14, 2020 Share Posted February 14, 2020 There are 5 parts to an ajax call generating the call (which you have shown us) The headers sent to the server the processing on the server the response returned the processing of the response (also shown) All of those need to be correct. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.