jQuery
function(data)
{
if(data === "importtrue")
{
$('#rebuildme').//function like .html
} else {
$('#rebuildme').//function like .html
}
});
with t开发者_运维知识库his, i'd like create html with PHP code.
HTML/PHP
<div id='rebuildme'><?php print_r( $_SESSION['ERROR'] );?>
The function is a result of a $.post and $_SESSION['ERROR'] is created on the page the ajax requests too.
In your jQuery you need to capture the result of that service call and append it to the DOM for #rebuildme if it returns anything valid. I would suggest making it return 404 or something semantic so that $.get() fails silently until it has something valid to return.
if(data === "importtrue"){
$.get('/myservice/import',function(data){
$('#rebuildme').append(data);
});
}
精彩评论