problems with jquery $.get -


it not first time use $.get function, time dont know why not working

function test(tid)   {     alert("1");    var ttt;    alert("2");    var ddd;     alert("3");     $.get("demo_ajax_load.txt", function(result){     alert("4");      });    } 

demo_ajax_load.txt text file content is: welcome

i getting alert 1,2,3 not showing 4th alert message. looks normal here, wrong simple function?

thanks

it have nothing wrong long not testing locally.

if you're using google chrome (i'm using version 20), open console (press f12) , see error:

origin null not allowed access-control-allow-origin.

enter image description here

in mozilla firefox,

[object xmldocument]

but if remotely (in host), working normally...

you can see live demo , open console see output if like.

my simple jquery:

$.when(     $.get("a.txt")   )  .done(function(data) {      console.log("all done: " + data);      $(".txt-from-file").text(data);    })  .fail(function(data) {      console.log("error found: " + data.statustext);      $(".txt-from-file").text(data.statustext);    }); 

or can simplify more , use:

$.get("a.txt").then(     function() { alert("succeeded"); },     function() { alert("failed!"); } ); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -