Q: How to call external PHP file in AJAX 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');
        }
    }
});


A: $.ajax({
    type: "GET",
    url: 'test.php',
dataType: 'jsonp',
    contentType: "text/html",
    crossDomain:'true',
    data: {uname: "admin", pass: "admin"},
    success: function (json) {
        //process the json here.
    }
});

You are using incorrect format for data field of ajax .
And no, Javascript doesn't normally allow you to access data via ajax from external servers.It will give out 

Origin http://externalhost is not allowed by
  Access-Control-Allow-Origin.

Edit:
However, You can set crossDomain  and dataType:'jsonp' for getting JSON data from an external server.
