1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    91
    Vote Rating
    2
    satishs is on a distinguished road

      0  

    Default Unanswered: Error in JSON response from PHP

    Unanswered: Error in JSON response from PHP


    I am trying to return a simple JSON response from PHP on server. The JSON response seems to be formatted correct - I've validated it, but for some reason I am getting

    Uncaught SyntaxError: Unexpected token :

    error and my store fails to load.

    I've tried setting content type to application/json as mentioned in many forums.

    <?php header('content-type: application/json; charset=utf-8');

    response seems to be interepreted as MIME type text/html - not sure if this is the problem, but couldn't get that changed.

    Here is the JSON response:

    {"sb3model":[{"sbfor":"Ayy","sbname":"Har","sbloc":"a"},{"sbfor":"Muruga","sbname":"Ska Sas","sbloc":"b"},{"sbfor":"Gan","sbname":"Maa Gap","sbloc":"c"}]}

    Any help will be great!.

    Thanks,
    ST

  2. #2
    Sencha User
    Join Date
    Feb 2012
    Posts
    91
    Vote Rating
    2
    satishs is on a distinguished road

      0  

    Default


    hi guys, I was able to get the Response Content-Type to be in applicaiton/json MIME type. But still running into this error- JSON is valid- this is driving me nuts,

    Uncaught SyntaxError: Unexpected token :





  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    91
    Vote Rating
    2
    satishs is on a distinguished road

      0  

    Default


    folks..it finally worked. being a newbie, every step seems to be a challenge, - but thanks to helpful posts on the web.

    here is what I had to do...

    After getting the MIME type straight.

    I changed the code to implement callback as it is JSONP

    echo json_encode(array('sb3m'=>$arr)) // this may be valid for a JSON response.

    to

    echo $_GET['callback'].'('.json_encode(array('sb3m'=>$arr)).')'; // key here $_GET... as this handles JSONP requests from a different server than responding server.

  4. #4
    Sencha Premium Member
    Join Date
    Oct 2011
    Posts
    61
    Answers
    3
    Vote Rating
    0
    dishwashwebdesign is on a distinguished road

      0  

    Default


    thanks for sharing.
    i had the same troubles working with node express but. this did the trick for me: http://vaboone.wordpress.com/2011/08...de-js-express/
    cheers

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi