javascript - Why wont this JSON work in IE -


it works on chrome , every other browser, not ie, i've made example below:

http://develop.davzy.com/test1.php

(talking ie 8, i'm not sure if runs okay in 9)

when run json request error says object expected. occurs on line 29.

<!doctype html>  <html>    <head>    <title>sandbox</title>      <script src="http://code.jquery.com/jquery-1.4.4.min.js"></script> </head>  <script>  function search() {     $.ajax({          url: 'http://davzy.com/cache/api/rarevalues.php?callback=?&search=' + $('input').val(),         cache: false,         datatype: 'json',         success: function(data, status, xhr) {             $('body').append('<br>' + data[0].name);             $('input').focus().val('');         }     }); }  </script> <body>      <div>type test or rare or chair</div>     <input onkeydown='if(event.keycode == 13) search();'>     <button onclick='search()'>go</button> </body> </html> 

and here example of json returns (the callback working fine, ignore ? http://davzy.com/cache/api/rarevalues.php?callback=?&search=petal)

    ?([{"0":"18","id":"18","1":"petal patch","name":"petal patch","2":"75","parent":"75","3":"cache\/rare_values\/images\/petal_patch.gif","small_image":"cache\/rare_values\/images\/petal_patch.gif","4":"cache\/rare_values\/images\/large\/petal_patch.gif","big_image":"cache\/rare_values\/images\/large\/petal_patch.gif","5":"a little bit of outdoors indoors..","motto":"a little bit of outdoors indoors..","6":"0","displayorder":"0","7":"1_center cache\/rare_values\/images\/petal_patch_1.png\n1_left cache\/rare_values\/images\/petal_patch_2.png","interactiveimages":"1_center cache\/rare_values\/images\/petal_patch_1.png\n1_left cache\/rare_values\/images\/petal_patch_2.png","hcs":12.5,"throne":0.06,"credits":"25"},{"0":"685","id":"685","1":"petals","name":"petals","2":"28","parent":"28","3":"cache\/rare_values\/images\/petal_flurry.gif","small_image":"cache\/rare_values\/images\/petal_flurry.gif","4":"cache\/rare_values\/images\/large\/petal_flurry.gif","big_image":"cache\/rare_values\/images\/large\/petal_flurry.gif","5":"romance in air. , rose petals apparently.","motto":"romance in air. , rose petals apparently.","6":"0","displayorder":"0","7":"","interactiveimages":"","hcs":1.5,"throne":0.01,"credits":"3"}]) 

strimp099 correct, needed header('content-type: application/json; charset=utf-8'); ie treat json. thanks!

strimp099 correct, needed header('content-type: application/json; charset=utf-8'); ie treat json. thanks!


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -