I’m using jQuery .load() to get info out of a database. Before loading the info into a div i would like to check the content with a if statement.
For example: (the ajax will return 1)
$('div.status').load("../files/ajax-calls.php?type=validatePerformer&performerId=265486");
if($('div.status').text() == 1){
alert("ajax input checked, value = 1");
}else{
return false;
}
i don’t know if it’s possible to check incoming ajax variables this way because jQuery write these directly into the DOM.
The solution i’m seeking would look like this (i know this isn’t correct coding, just to give an idea)
var ajaxResult = $('div.status').load("../files/ajax-calls.php?type=validatePerformer&performerId=265486");
if($(ajaxResult) == 1){
$('div.status').text(ajaxResult);
}else{
return false;
}
Thanks in advance!
You can pass a callback to the
.loadfunction……but it won’t prevent jQuery from inserting the new content, since this is done before the callback occurs.
To manually insert based on a condition, you should probably use
$.getinstead.