i have 2 files index.html(local file in hard drive part of web app) , just.txt(on local server) when send ajax request contents in just.txt should displayed in alert box. here have in index.html
$(document).ready(function () { $.ajax({ url:"http://localhost/ajaxtest/just.txt", datatype: 'jsonp', success: function (response) { alert(response); $("#container").html(response); } }); }); and just.txt includes single line
hello when open index.html following error
referenceerror: hello not defined
where hello word in just.txt file. neither alert box nor #container changed.
but when put both these files on local server issue solved , alert box saying hello , #container modified.
i don't want index.html web app file must stored locally , just.txt file must stored in external server.
use datatype : 'text' instead of datatype : 'json'
with 'json' datatype javascript tries parse loaded content json , throws exception
Comments
Post a Comment