jQuery .load() not working

前端 未结 4 369
日久生厌
日久生厌 2020-12-10 12:46

On my website, I\'m trying to pull the content of a post in my forum (hosted on the same domain) and display it in a div on the homepage, using jQuery.

Here\'s the c

相关标签:
4条回答
  • 2020-12-10 13:23

    your code should be something like this

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
    

    js code

     <script type="text/javascript">
       jQuery(document).ready(function(){
           jQuery("#contain").load("http://examplepage.com/forum/showthread.php?tid=NN #pid_NN");
       });
    </script>
    
    0 讨论(0)
  • 2020-12-10 13:35

    You need a closing </script> tag on your jQuery include, and you need to wait for dom load.

    JS

    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    
    <script type="text/javascript">
        jQuery(document).ready(function(){
            jQuery("#contain").load("http://examplepage.com/forum/showthread.php?tid=NN#pid_NN");
        });
    </script>
    

    HTML

    <div id="contain"></div>
    
    0 讨论(0)
  • 2020-12-10 13:42

    .load can pass your GET params seperate:

    .load("link to php", "http://examplepage.com/forum/showthread.php", "tid=NN#pid_NN")
    
    0 讨论(0)
  • 2020-12-10 13:42

    Check this code. you should use ">*" after container id to load content specific container on the page.

    jQuery('#contain').load("http://example.com/pageurl #somecontaineronpage >*",function(){
          //after loading completion code goes here                      
    });
    

    Hope, this will help

    0 讨论(0)
提交回复
热议问题