Monday, 26 August 2013

Javascript retrieving username from db

Javascript retrieving username from db

I'm trying to write a JavaScript function that retrieves surname that
corresponds to a supplied email address with no success so far. Here's my
code:
function getUsername(){
var username;
$(function(){
var dataString = 'email=' + EMAIL_ADDRESS;
$.ajax({
url: 'user_crud_operations.php',
data: dataString,
dataType: 'json',
success: function(data){
U = data[1];
username = data;
}
});
});
return username;
}
I need to use the retrieved username in another function elsewhere. Where
am I going wrong?

No comments:

Post a Comment