Jquery .ajax()本地测试 [英] Jquery .ajax() local testing

查看:139
本文介绍了Jquery .ajax()本地测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的.ajax函数,试图在文档准备好后加载一些内容。

I've got a little .ajax function which trying to load some content after document is ready.

$(document).ready(function(){
$.ajax({
        url: 'php/accounts-blocks.php',
        cache: false,
        beforeSend: function() { $('#accounts-blocks').html('Please wait...'); },
        success: function(html) { $('#accounts-blocks').html(html); }
        });
});

但是,当我尝试在本地测试此页面时(仅在我的电脑上),ajax显示只有请等待的消息就像永远一样,并且不会加载任何内容。我应该安装本地托管或类似的东西来测试AJAX功能,还是脚本有问题?

However, when I'm trying to test this page locally (just on my PC), ajax shows up only "Please wait" message like forever, and doesn't load any content. Should I install local hosting or something like that in order to test AJAX functionality, or is it something wrong with script?

推荐答案

Ajax在没有安装本地Web服务器的情况下在本地运行脚本时,(XHR)在某些浏览器(例如Firefox等例外)中不起作用。 Chrome是一个不允许使用的示例。

Ajax (XHR) will not work in some browsers (there are exceptions such as Firefox) when running the script locally without having a local web server installed. Chrome is an example that will not allow it.

使用安全性较低的浏览器,或者安装本地HTTP服务器。

Use a browser with less strict security, or install a local HTTP server.

这篇关于Jquery .ajax()本地测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆