简体   繁体   中英

JSON.stringify not working properly in firefox?

i'm trying to stringify one object in javascript. In IE, after stringify the values are looks

{"jobTypeArray":"[CONTRACT -W2]"}

But in Firefox & Chrome values looks

{"jobTypeArray":"[\"CONTRACT -W2\"]"}

unterminated strings are appended in json.

Here is my Code,

var cbJobData = new Object();
var JobTypevalues = [];
for (var i = 0; i < selectJobTypeVal.options.length; i++ ) {
    if (selectJobTypeVal.options[i].selected) {
        JobTypevalues.push(selectJobTypeVal.options[i].value);
    }
}
cbJobData.jobTypeArray = JobTypevalues;

now i'm going to stringify In this cbJobdata , in this place i facing the issue

how to solve this issue. Is json.stringify is IE attribute ?

anybody can help me ? thanks in advance

This behaviour is happening by the Browser itsself for security reasons...

You have to stripslashes .. In your Backend side

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM