Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts

    jQuery and getJSON

    Hi,

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

    HTML:
    Code:
    <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:

    Code:
    {'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.
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    First thing I want to know is what happens when you put that URL in a browser. What comes back?

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Location
    N. Ireland
    Posts
    351
    Thanks
    16
    Thanked 4 Times in 4 Posts
    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.
    Daemonkin.
    If this was helpful, please add to my reputation
    Thousand Sons - Freelance Web Developer - ninetyonedegrees.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •