...

View Full Version : jQuery and getJSON



daemonkin
10-18-2010, 11:53 AM
Hi,

Looking to figure out why my simple page is not returning what I expect.

HTML:


<html>
<head>
<title>IBM Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<meta http-equiv="content-script-type" content="text/javascript">
</head>
<body>
<script type="text/javascript">
alert("Here");
$.getJSON("http://mylocalIP/~rmccallum/c/ibm-json.html?callback=?",
function(data) {
alert("Symbol: " + data.symbol + ", Price: " + data.price);
});
</script>

</body>
</html>


And the JSON file:


{'symbol': 'IBM', 'price': '91.42'}

The first alert is fired off but the second one in the JSON function does not work. Any thoughts?

D.

Fumigator
10-19-2010, 03:51 AM
First thing I want to know is what happens when you put that URL in a browser. What comes back?

daemonkin
10-19-2010, 08:41 AM
Hi Fumigator.

Thanks for the question. The returned value is:

({"symbol": "IBM", "price": "91.42"})

for the url:

http://mylocalIP/~rmccallum/c/ibm-json.html?callback=?

Does this shed any light?

D.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum