I have a page where i am using the wikipedia api. But since i cannot use JSON for cross domain restrictions i use JSONP. My code looks like this
<body>
<script type="text/javascript">
function res(data){
alert(data);
};
</script>
<script type="text/javascript" src="http://en.wikipedia.org/w/api.php?action=opensearch&search=api&callback=res&limit=10&namespace=0&format=jsonfm">
</script>
</body>
here i am providing the callback function named res in the url. As i saw in firebug the response came as
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MediaWiki API Result</title>
</head>
<body>
<br />
<small>
You are looking at the HTML representation of the JSON format.<br />
HTML is good for debugging, but probably is not suitable for your application.<br />
See <a href='http://www.mediawiki.org/wiki/API'>complete documentation</a>, or
<a href='/w/api.php'>API help</a> for more information.
</small>
<pre>
res([
"api",
[
"API",
"Apiales",
"Apiaceae",
"Apia",
"Apicomplexa",
"Apicomplexa lifecycle stages",
"Apidae",
"APIA Leichhardt Tigers",
"Apical membrane",
"Apical consonant"
]
])
</pre>
</body>
</html>
This means that the server is sending the response enclosed in the callback function res but this function is not executed by the browser(the alert is not being called).I am using firefox 5. Whats wrong with this?
It says it right there in the response:
try