My jQuery script as below:
jQuery.ajax({
type:"GET",
url:url,
data:'action=getStatus',
}).done(function(response){
var data = jQuery.parseJSON(response);
var test = data['visitor_chart'];
})
My jQuery.ajax return response in below form:
"{"visitor_chart":"{y: 3, label: \"2015-07-21\"}, {y: 1, label: \"2015-07-29\"}, {y: 1, label: \"2015-07-30\"}, {y: 1, label: \"2015-08-01\"}","visitor_count":6,"enquiry_count":1}"
After parseJSON
I got data['visitor_chart']
in below form:
"{y: 3, label: "2015-07-21"},{y: 1, label: "2015-07-29"},{y: 1, label: "2015-07-30"},{y: 1, label: "2015-08-01"}"
but I want to strip first and last quote from this string.
How to do that?
to replace first quote :
str=str.replace(/^"/, "");
to replace last quote :
str=str.replace(/"$/, "");
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.