jquery ignores response

By : Neil G
Source: Stackoverflow.com

Hi anyone see why my alert won't 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},
			  		  }, "json");

Response from backend.php is

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


While I dont think its your problem, the callback function does take a 2nd parameter (the jQuery docs call it "textStatus") which is a textual representation of the HTTP status. Specify a 2nd argument to your callback.

function(data, textStatus) { ...

Why is 'backend' at the start of your response? I would start by removing that. Everything from { to } looks good.

This video can help you solving your question :)
By: admin