How can I use some data as global
? For example:
$.ajax({
type: 'GET',
url: "php/setting.php",
data: { name: name, lastname: lastname, firstname: firstname
}
dataType: 'html',
context: document.body,
async: false,
success: function(data) {
//how to get this name,lastname, and firstname
}
});
How can I get this name, lastname, firstname, and use it as a global variable
like:
if(name == 'archie') {
}
thanks.
I don't know if I fully understand the question but I think what you want to do is to set up an empty variable in your namespace (or in the global namespace if that's how you're doing it) such as var name;
and then when you perform your AJAX request you want to do something like
success: function(data) {
name = data.name
}
var name="the name";
var lastname="the lastname";
var firstname="the firstname";
$.ajax({
type: 'GET',
url: "php/setting.php",
data: { name: name, lastname: lastname, firstname: firstname},
dataType: 'html',
context: document.body,
async: false,
success: function(data) {
if(name == 'archie') {
//you can use it
}
}
});