开发者

How to load script and html content from a url using jquery?

I have a html page in which i have a div where i need to load content from another page, which contains javascript and html. if i load as plain html, the html doesn't开发者_开发知识库 work.

so is there anyway make the javascript to work the way it has to and the html too when loading it using ajax.


<script type="text/javascript">
   $(document).ready(function(){   
    $("#myDiv").load("myPage.html");
   });
</script>


If I'm reading this properly, then you might not be-able to do this, there are all sorts of mechanisms to stop javascript from accessing data from other places, due to security concerns.

However, can you not simply just use an IFrame ?


$(document).ready(function(){ $('#result').load('ajax/test.html'); });

else try this

$('#result').load('ajax/test.html', function() { alert('Load was performed.'); });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜