开发者

I am extracting data from an external URL and unable to get the javascript functions working

开发者 https://www.devze.com 2023-03-28 04:24 出处:网络
I want to load the external page\'s data into a div along with the javascript functions(though the js file is same for both of them, the functions do not work). The file loads fine into th开发者_开发技

I want to load the external page's data into a div along with the javascript functions(though the js file is same for both of them, the functions do not work). The file loads fine into th开发者_开发技巧e page, but the javascript function don't work properly. My Code-

var emaild = $("#hidden").val(); 
var div = $("#mydiv");
   var refreshId = setInterval(function() {
      $.getScript("js.js", function() {
      div.html($("#load").load('posts.php?id='+emaild));
});
   }, 6000);
   $.ajaxSetup({ cache: false });

Thanks in advance. Hope I get a solution soon! :D


You may have a problem here:

div.html($("#load").load('posts.php?id='+emaild));

$.html() expects an html string and you're giving it a deferred instead. It may not be the cause of your script not running, but good to eliminate anyhow.

Is there a reason why you're using $("#load").load when you want the output of the call to go inside div. In other words, isn't this what you really want?

div.load('posts.php?id=' + emaild);

0

精彩评论

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