admin管理员组

文章数量:1405601

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?

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?

Share Improve this question edited Jun 12, 2014 at 8:37 MrCode 64.6k10 gold badges92 silver badges113 bronze badges asked Apr 14, 2014 at 9:48 DazvoltDazvolt 6972 gold badges10 silver badges22 bronze badges 1
  • What does the developper toolbar shows on XHR request? What is the status of the request? – D4V1D Commented Apr 14, 2014 at 9:50
Add a ment  | 

1 Answer 1

Reset to default 6

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.

本文标签: javascriptJquery ajax() local testingStack Overflow