Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 使用AJAX和jQuery加载内容_Html_Jquery - Fatal编程技术网

Html 使用AJAX和jQuery加载内容

Html 使用AJAX和jQuery加载内容,html,jquery,Html,Jquery,我是jQuery的新手,并且尝试使用以下代码动态加载AJAX和jQuery内容,但它不起作用 <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> <script type="text/javascript"> $(document).read

我是jQuery的新手,并且尝试使用以下代码动态加载AJAX和jQuery内容,但它不起作用

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("button").click(function()
{
$(".text").load("http://api.jquery.com/get/");

});

});
</script>
<title>AJAX with jQuery</title>
</head>
<body>
<div class="text">Sushil</div>
<button>Load Text</button>
</body>
</html>

$(文档).ready(函数()
{
$(“按钮”)。单击(函数()
{
$(“.text”).load(“http://api.jquery.com/get/");
});
});
AJAX与jQuery
苏希尔
加载文本

您违反了同一原产地政策。只要打开控制台,单击按钮时就会看到错误消息。事情对你来说会变得更清楚。如果没有,请返回

我运行了您的代码,并出现以下错误: 无法加载XMLHttpRequest。访问控制允许原点不允许原点为null


我在谷歌上搜索了一下,结果是:

我试图使用$(“.text”).load(“txtfile.txt”)在同一目录下加载一个本地html文件,但仍然没有结果。你能给我一个如何使用AJAX在div中加载文件的例子吗?如果两个文件都在同一个目录中,你的代码对我来说非常适合。。你能告诉我你犯了什么错误吗。。。只要打开控制台,你就会知道这个电话的错误。。好的,你用什么浏览器呢?告诉我们我用过firebug,你也可以用谷歌chrome开发者工具(Ctrl+Shift+I)