I am creating a website in which , I am inserting data into database using ajax XMLHttpRequest().
From php file I am sending response like this.
$response = array();
$response["success"] = 1;
echo json_encode($response);
In javascript file I am getting response as.
var json = xmlhttp.responseText;
Now while executing, var json contains response with some additional texts
{"success":1}< !--first comments --> < script> an script from server < /script>< !--second comments -->
I want to parse only json text {"success":1} using javascript, plz don't suggest jquery approach.
I tried var obj = JSON.parse(json);, but it did not work.