I have code to check username and password in test.php file.
But when I am calling this ajax it is always showing alert of wrong username and password.
Can anyone tell where I am going wrong?
$.ajax({
type: "GET",
url: 'http://externalurl/external/test.php',
contentType: "text/html",
data: 'uname=' + uname + '&pass=' + pass,
success: function (data) {
if (data == 'success') {
alert('success');
} else {
alert('Wrong user name and password.Please try again');
}
}
});
You are using incorrect format for
datafield of ajax .And no, Javascript doesn’t normally allow you to access data via ajax from external servers.It will give out
Edit:
However, You can set
crossDomainanddataType:'jsonp'for getting JSON data from an external server.