Answer the question
In order to leave comments, you need to log in
How to determine the desired response from php json_encode in jq?
in php, when all checks passed successfully, try to send response
echo json_encode(array("success" => $result, "pagi" => $pagi), JSON_UNESCAPED_UNICODE);
$.ajax({
url: '...',
type: 'post',
dataType: 'json',
data: ...,
success: function(json){
if(typeof json.success !== 'undefined'){
$(document).find('.loadItemsHere').html(json.success);
}
else if(typeof json.error !== 'undefined'){
alert(json.error);
}
else if(typeof json.pagi !== 'undefined'){
$(document).find('.loadItemsHere').after(json.pagi);
}
}, error: ....
echo json_encode(["success" => $result], JSON_UNESCAPED_UNICODE);
echo json_encode(["pagi" => $pagi], JSON_UNESCAPED_UNICODE);
Answer the question
In order to leave comments, you need to log in
if(typeof json.success !== 'undefined'){ $(document).find('.loadItemsHere').html(json.success); } else if
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question