php json_encode & jquery parseJSON single quote issue

后端 未结 5 2055
庸人自扰
庸人自扰 2020-12-24 01:40

I searched and read most of the related topics, but they weren\'t what I was looking for.

I\'ve a JSON enocded string with json_encode PHP function:

5条回答
  •  不知归路
    2020-12-24 01:52

    The issue you are facing is that you are presenting the results of the json_encode call to JavaScript as a string whereas it is valid JavaScript. Remove the jQuery.jsonParse set out of the output and simply assign the echoed results to the JavaScript variable in question.

    var obj = array(
        "Matthew Modine","Adam Baldwin","Vincent D'Onofrio"
    ),"year"=>1987)); ?>;
    

提交回复
热议问题