Thanks Roan, that helped a bit. You were correct, the myFunc() definition had to be placed before the src. Through further research I discovered (what I believe is) the exact API call that I need for the output that I desire. However, I'm still having trouble with JavaScript accessing the returned value from the callback. At this point, I'm trying to assign the callback value to a variable and print it to the screen to confirm that I have what I'm after. So far, the only value I've been able to retrieve from the callback is:
[object Object]
What I'm after is what is printed to the screen when you go to the following link:
http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&action=query&prop=revisions&rvprop=content&titles=play
Does anybody see where I'm going wrong or have any suggestions?
/////////////////////////////////////////////////////
<html>
<body>
<script type="text/javascript" >
//myFunc("hello");
function myFunc(str){
document.write(str);
//var testVar = JSON.parse(str);
//document.write(testVar);
//location.href = "http://www.myURL.com/test.php?str="+str;
}
</script>
<script type="text/javascript" src="http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&action=query&prop=revisions&rvprop=content&titles=play"></script>
</body>
</html>
/////////////////////////////////////////////////////
Thanks again,
Aaron.
2010/6/15 Aaron Ward <edugamer@gmail.com>:
> <script type="text/javascript"I'm not sure you can mix src="" with content like that. Try using 1)
> src="http://en.wiktionary.org/w/api.php?format=json&callback=myFunc&action=opensearch&search=play">
> function myFunc(str){
> document.write(str);
> document.write("Hrm");
> }
> </script>
>
separate tags for the src="" script and the myFunc() definition and 2)
putting the myFunc() definition *before* the src=""
Roan Kattouw (Catrope)
_______________________________________________
Mediawiki-api mailing list
Mediawiki-api@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api