function SubmitForm(method) { var login =...">

Jquery ignores response

Hello everyone, why won't my warning work?

 <script type="text/javascript">
 function SubmitForm(method)
 {
  var login = document.form.login.value;
  var password = document.form.password.value;
  $.post("backend.php", { 
                        login: login, 
                        password: password, 
                        method: method},
                        function(data){
                        alert(data.message); 
                        console.log(data.refresh); 
                      }, "json");
            }
   </script>

      

Response from backend.php

backend{"message":"Log in credentials are not correct","refresh":"false"}

      

+1


a source to share


3 answers


Why "backend" at the beginning of your answer? I would start with this. Everything from {to} looks good.



+1


a source


While I don't think this is your problem, the callback function takes a second parameter (the jQuery docs call it "textStatus"), which is a textual representation of the HTTP status. Provide a second argument for your callback.



function(data, textStatus) { ...

      

0


a source


Great_llama was right, for some reason I had a "backend" repeating another script. Removed that and all.

0


a source







All Articles