Answer the question
In order to leave comments, you need to log in
How to find out if there is a certain variable in the json response or not without js errors?
In general, there is a script
$('form').submit(function(e){
e.preventDefault();
$form = $(this);
$form.find('.notice').html('');
$button = $form.find('button');
$button.addClass('loading');
$action = $form.attr('action');
$.ajax({
'url': $action,
'type': "POST",
'dataType': "json",
'data': $form.serialize(),
'success': function(json) {
if(json.addons.redirect != null){
alert('yes');
}
$button.removeClass('loading');
$form.find('.notice').html('<div class='+json.response+'>'+json.msg+'</div>');
}
});
});
function ResponseCreate($response, $msg, $data){
$datas = array(
"response" => $response,
"msg" => $msg,
"addons" => $data,
);
$data_string = json_encode($datas);
exit($data_string);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question