PHP end of process looks like following:
$output = array(
'inputUrl' => 'some_value',
'title' => 'some_value',
'slug' => 'some_value',
);
echo json_encode( $output );
I get response like:
{"inputUrl":"some_value","title":"some_value","slug":"some_value"}0
AJAX is like:
jQuery.post(
"ajax.php",
{ 'action': 'store', 'url': url },
function(data) { alert(data); }
);
I have 2 questions:
- Why that
0
comes up in the end of response? - I tried
JSON.parse(response);
but not working. How to part elements of the response array injQuery
?
Question 1 is solved by using die()
after the echo
or wp_die()
in WordPress.
Can someone help me with Question 2?