开发者

AJAX page fetch ignores javascript on page

开发者 https://www.devze.com 2023-04-10 17:32 出处:网络
I am calling an ajax script to fetch a content of a page and then replace the current contents with the fetched one. One problem I am facing is that there is a j开发者_StackOverflowavascript on the fe

I am calling an ajax script to fetch a content of a page and then replace the current contents with the fetched one. One problem I am facing is that there is a j开发者_StackOverflowavascript on the fetched page which doesnt get rendered and is treated as text. How do I make sure that the javascript gets loaded?


write javascript(fetched page) code in main page.

for example:

$.ajax({
    url: "your fetched page url", 
    dataType: "html",
    type: 'POST',
    data: "your data", 
    success: function(data){ 
    $("#result").html(data); //call back div
        //put your javascript code from fetched page here               
    }
});
0

精彩评论

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

关注公众号