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(/"$/, "");
Verified here. It's working
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With