The script attaches to the body like it should, but I can't figure out how to access the data. I understand that there should be some sort of jsonRequest function call, but I'm completely stumped as to what it would look like. here's my lame attempt thus far:
even if you corrected the obvious typo's
in that code it still will not work for you
unless you change the file found at http://qa-find.uglii.com/Home/GetCou...8c31b6a84.json
or place some server side
code at that url.
Clearly. So I thought that, like you said, it must just be typo's and that changing all the references from jsonRequest to jsonpRequest might do something, but no dice - no error, but the callback function doesn't even run.
Clearly. So I thought that, like you said, it must just be typo's and that changing all the references from jsonRequest to jsonpRequest might do something, but no dice - no error, but the callback function doesn't even run.
so...
here is another typo ...
else url = '&jsonp='+jname;
Quote:
Originally Posted by DaveyErwin
even if you corrected the obvious typo's
in that code it still will not work for you
unless you change the file found at http://qa-find.uglii.com/Home/GetCou...8c31b6a84.json
or place some server side
code at that url.
I don't really know enough about what I'm doing to spot the errors - is that line supposed to be else url += '&jsonp='+jname;?
but your quoted comment confuses me - isn't the point of jsonp meant to be that you can do this kind of thing without having to have access the target document?
But maybe you're right, and that it is a problem with the file - the other jsonp examples out there seem to work fine on other files but not on this one. The closest I got was with the yahoo yql, which I was hoping to avoid as it seems to be just adding another step in the process, but at least it gets a result...
Code:
<body>
<select id="addoptions" onchange="alert(this.value)"></select>
<script type="text/javascript">
function makeList(o){
result=o.query.results.json.json
for (var x = 0; x < result.length; x++) {
document.getElementById("addoptions").options[x]=new Option(result[x].n,result[x].i);
}
document.getElementsByTagName('body')[0].removeChild(scr);
}
var myurl=encodeURIComponent("http://qa-find.uglii.com/Home/GetCountries/9a3d0a019-e523-487f-8250-fd98c31b6a84.json")
var filetype="json"
var sel="*"
var scr=document.createElement("script");
scr.type="text/javascript"
scr.src='http://query.yahooapis.com/v1/public/yql?q=select%20'+sel+'%20from%20'+filetype+'%20where%20url%3D%22'+myurl+'%2F%22&format=json&callback=makeList';
document.getElementsByTagName('body')[0].appendChild(scr);
</script>
</body>
even if you corrected the obvious typo's
in that code it still will not work for you
unless you change the file found at http://qa-find.uglii.com/Home/GetCou...8c31b6a84.json
or place some server side
code at that url.
even if you corrected the obvious typo's
in that code it still will not work for you
unless you change the file found at http://qa-find.uglii.com/Home/GetCou...8c31b6a84.json
or place some server side
code at that url.
yeah - you should have seen all the variations in between
but this is kind of my point: works same-domain (post #12) doesn't work cross-domain (post#1)
I've pretty much given up, anyway... the code in 1 works on other json files (once the typo's are corrected), so I guess it's just something about that one