开发者

rebuild html on jquery condition

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);
  });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜