weixin_33709609 2014-04-14 09:48 采纳率: 0%
浏览 39

jQuery .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); }
        });
});

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?

  • 写回答

1条回答 默认 最新

  • 零零乙 2014-04-14 09:50
    关注

    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.

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

    评论

报告相同问题?