开发者

rebuild html on jquery condition

开发者 https://www.devze.com 2023-02-10 06:56 出处:网络
jQuery function(data) { if(data === \"importtrue\") { $(\'#rebuildme\').//function like .html } else { $(\'#rebuildme\').//function like .html

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

精彩评论

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