I'm having trouble getting a response from a jQuery ajax call ...
(This is a script to authenticate the user, and he needs to return his name and user ID. I realized that I can encode it as JSON and receive data in the format below.
It returns an "undefined" error for warning () .
javascript
$.ajax({
type: "POST",
url: "myURL.php",
data: {username: username, password: password},
success: function(results) {
alert('Hi '+results.name);
}
});
PHP (myURL.php)
json_encode(array(
'id'=>1,
'name'=>'Basil Fawlty'
));
Any help or ideas on where I'm going wrong would be greatly appreciated!
Thank.
Solution: The solution added a data type.
source
share