JQuery/Json Issue ... Please Help?

Discussion in 'jQuery' started by mokimofiki, Jul 13, 2011.

  1. #1
    Currently we have a page that returns a partners information that can be found at:
    http://www.muzak.com/assets/ZipCodeLookup/index.php?zipcode=28037&callback=?
    (above is an example with the zipcode already added)

    and we are trying to pull the information and save them in hidden form fields using the following code:
    var zpcode = document.getElementById('PostalCode').value;
    jQuery.getJSON("http://www.muzak.com/assets/ZipCodeLookup/index.php?zipcode=" + zpcode + "&callback=?", 
    function(data) {
    		
    	$("#DealerIA_OA").val('');
    	$("MuzakDealer").val('');
    	
    	$("#DealerIA_OA").val(data["ia_or_oa"]);
    	$("#MuzakDealer").val(data["name"]);
    
    });
    
    });
    Code (markup):
    Any help would be greatly appreciated. Thank you in advance.
     
    mokimofiki, Jul 13, 2011 IP
  2. joshpeyton

    joshpeyton Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Be sure you are getting the callback on your index.php page.

    Example:
    print $_GET['callback']. '('.json_encode($data).')';
     
    joshpeyton, Jul 13, 2011 IP
  3. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #3
    Thanks I was missing "$_GET['callback']." everything works fine now. Nice find :)
     
    mokimofiki, Jul 14, 2011 IP
  4. NsaneNoob

    NsaneNoob Peon

    Messages:
    2,103
    Likes Received:
    59
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Also, remember, you can write your json by yourself.
     
    NsaneNoob, Jul 18, 2011 IP