How to get the html of a div on another page with jQuery ajax?

前端 未结 5 1087
忘掉有多难
忘掉有多难 2020-11-27 12:30

I\'m using jQuery\'s ajax code to load new pages, but wanted him to get only the html of a div.

My codes: HTML:


    
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 13:10

    If you are looking for content from different domain this will do the trick:

    $.ajax({
        url:'http://www.corsproxy.com/' +
            'en.wikipedia.org/wiki/Briarcliff_Manor,_New_York',
            type:'GET',
            success: function(data){
               $('#content').html($(data).find('#firstHeading').html());
            }
    });
    

提交回复
热议问题