开发者

Different versions of jQuery causing a some problems

开发者 https://www.devze.com 2023-03-25 13:10 出处:网络
When ever I send back a JSON array via AJAX; one of the objects will be \"error\":true/false. It worked fine in version 1.4.2; but since then I have changed to 1.6.2. On 1.6.2 I have built modal scrip

When ever I send back a JSON array via AJAX; one of the objects will be "error":true/false. It worked fine in version 1.4.2; but since then I have changed to 1.6.2. On 1.6.2 I have built modal script but when I put it live I was getting an error with the JSON array saying that property "error" does not exist, or something along those lines, when it does.

I tried changing back to previous version of 1.4.2 but then I had a problem with the modal; mentioning a problem to do with 'handle' somewhere on the jQuery script itself.

I don't know if anyone has experienced the same problem but do开发者_JAVA技巧es anyone know how to fix it?

Many thanks

Edit: It return a string like this: {"error":false, "data":[{"element":"currentweather","html":"Rain"},{"element":"currenttemp","html":"22°C"}]} I'm not sure if it's anything to do with the array?


You can fix the JSON error by double-quoting the value:

"error": "true/false"

since JSON is parsed in a strict manner.


Might seem silly, but try to add the "error" property yourself?


This is weird; server side if I put json_encode an already json encoded array it works! i.e. json_encode(json_encode($json));

0

精彩评论

暂无评论...
验证码 换一张
取 消