JQuery.ajax () local testing

I have a little .ajax function that tries to load some content after the 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 try to check this page locally (only on my PC), ajax only shows the message β€œWait,” as forever, and does not load the content. Do I have to install local hosting or something like that in order to test AJAX functionality or something is wrong with the script?

+6
source share
1 answer

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

Use a less secure browser or install a local HTTP server.

+6
source

All Articles