Jquery load doesn't work

前端 未结 4 1295
一生所求
一生所求 2021-01-19 04:13

The jquery load in the below code doesn\'t work. What I\'m missing here?





        
4条回答
  •  清歌不尽
    2021-01-19 04:43

    You are requesting a page that is on a different domain so Cross-Domain-Policies apply. You can only access data cross-domain if the remote-server allows it (and only using JSONP I believe, anyone please correct me if I'm wrong on this). If you want to grab the source of a Google page, you will need to do it with a server-side script as a proxy for your jQuery:

    $(function() {
    
        //notice the client-side code (JS) is requesting a page on the save domain
        $("#dialog").load('my-script.php #maia-main');
    });
    

    And in my-script.php you would grab the remote page you want:

    
    

    Docs for file_get_contents(): http://www.php.net/file_get_contents

提交回复
热议问题