ajax errors appear on failure but not on success <p>I have a request form. which was working before but today its stopped working properly. What happened when I submit form, If form have any error it appears on the screen and also on the network. But when form is submit without any error no success message appears on the screen or on the network. also tried in console.log the result was null.</p> <pre><code>$(document).ready(function (e) { $("#contactForm1").on('submit',(function(e) { e.preventDefault(); $('p.error').empty(); $('#loader').show(); $.ajax({ url: siteurl, type: "POST", data: new FormData(this), contentType: false, cache: false, processData:false, dataType:"json", success: function(data){ if(data.error){ $('#loader').hide(); $( "p.error" ).empty(); $('p.error').css('display','block'); $("p.error").append(data.msg); }else { $('#loader').hide(); $( "p.error" ).empty(); $('p.error').css('display','block'); $("p.error").append(data.msg); window.setTimeout(function(){location.reload()},3000) } } }); })); </code></pre> <p>Code on ajax request url</p> <pre><code>$bussines_name=$_POST['bussiness_name']; $email= trim(sanitize_text_field($_POST['emailaddress'])); $url=trim(sanitize_text_field($_POST['websiteaddress'])); $address=trim(sanitize_text_field($_POST['address'])); if(empty($bussines_name) ) { echo json_encode(array( 'error' =&gt; true, 'msg' =&gt; 'Please enter your Business Name' )); exit; }elseif(empty ($url)){ echo json_encode(array( 'error' =&gt; true, 'msg' =&gt; 'Please enter your Unique Booking Code' )); exit; }elseif (empty ($email)) { echo json_encode(array( 'error' =&gt; true, 'msg' =&gt; 'Please enter your email address' )); exit; }elseif(empty($address)){ echo json_encode(array( 'error' =&gt; true, 'msg' =&gt; 'Please enter your address' )); exit; } else { echo json_encode(array( 'error' =&gt; false, 'msg' =&gt; 'Form submit successfully.' // **this msg is showing before but not now.** )); } </code></pre> <p>Any help will be apprecited.</p>