Sending PHP json_encode array to jQuery

前端 未结 4 1443
攒了一身酷
攒了一身酷 2020-12-10 22:07

ok, i guess I need help ! I searched with every keyword I could think off, but I still cant figure out, please help. Am more of a php guy, and I\'ve just started with jQuery

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 22:57

    You must parse the JSON response. jQuery has this built-in functionality (thankfully, because otherwise IE6 and 7 don't natively support JSON). Set a variable equal to this:

    $.parseJSON(response)
    

    And then, if you're not familiar with JSON format, check the response headers (using Firebug or similar,) and that will help you pick which keys' values you want. If you're looping, I would look into for in statements once the response has been parsed.

    EDIT: Using $.getJSON, the parsing is done automatically. Write less, do more. :)

提交回复
热议问题