Answer the question
In order to leave comments, you need to log in
Ajax not reloading the page?
Here is such a problem.
There is a login page: mysite.com/account/login. When the user enters the account through php and json, the code goes
$result ='Успешно!';
$result = array('eror' => $result);
echo json_encode($result);
exit;
result = jQuery.parseJSON(response);
document.getElementById(result_form).innerHTML = result.eror;
if(result.eror == 'Успешно!'){
document.location.href = "http://www.mysite.com/index.php"
}
Answer the question
In order to leave comments, you need to log in
Everything is bad here. I think that the problem is in the encoding and your strings are simply not equal. Return the digital error code and check it. If it's very rude, then so be it.
if (все прошло как надо) {
$result = array('code' => 1, 'message' => 'все сработало, как надо');
} else {
$result = array('code' => 2, 'message' => 'все очень плохо, произошла такая-то ошибка');
}
echo json_encode($result);
exit;
if (result.code == '1'){
window.location.href = "http://www.mysite.ru/index.php"
}
else {
document.getElementById(result_form).innerHTML = 'Error ' + result.code + ': ' + result.message;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question