ajax.responseText returns blank
this is a function part of a bigger project that's supposed to return the value of a specific attribute from a database.
-
$.extend({
loadAttribute: function() {
var args = arguments[0] || {};
var attribute = args.attribute;
var att_value = $.ajax({
type: "POST",
url: "db_output.php",
global: false,
dataType: "html",
data: "attribute=" + attribute,
error: function(){
alert('Error connecting to the database.');
},
success: function(msg) {
alert(msg);
}
}).responseText;
alert(att_value);
return att_value;
}
});
The
alert(msg) reports the correct value, but the function returns blank for the value of
att_value
what did I miss?
This is my first big project with jQuery ajax and I'm trying to follow the examples from jquery.com as closely as I can..