doumao1519 2017-09-15 12:54
浏览 33

Jquery .load函数响应

I'm trying to display response of PHP script within a div element <div id="divname"></div>

jQuery('#divname').load('TEST.php',{
  'id' : id
});  

My code works as expected and successfully insert «1» inside this div.

TEST.php file:

<?php
  echo '1';
?>

...but I would also like to alert the response in the same time using jQuery, someting like this:

jQuery('#divname').load('TEST.php',{
  'id' : id
}, 
alert(response); //????
);  

Can You help me?

  • 写回答

3条回答 默认 最新

  • douchu2823 2017-09-15 12:59
    关注

    Use the callback function , documentation

    jQuery('#divname').load('TEST.php',{
           'id' : id
      },  function() {
      alert( "Load was performed." );
    });
    
    评论

报告相同问题?