简体   繁体   中英

alert is not working on error message

// Alert is not working on error message , I want to insert only few 4 issue after that it should not work.

 success: function(msg, String, jqXHR) { window.location = 'home.html'; $("#result").html(msg, String, jqXHR) alert("Data Uploaded: "); if (msg.success == 'Error') { alert("Please close the previous issue"); window.location = 'home.html'; } 

// here (msg.success=='Error') is not working i want to display this message - "Please close the previous issue" on this .

Hope this works for you.

 $(document).ready(function(){ $('#your_form').submit(function(event) { event.preventDefault(); dataString = $("#your_form").serialize(); $.ajax({ type: "post", url: "post.php", dataType:"json", data: dataString, success: function (response) { if(response.status === "success") { // do something with response.message or whatever other data on success alert("Data Uploaded: "); window.location='home.html'; } else if(response.status === "error") { alert("Please close the previous issue"); window.location='home.html'; } } }) return false; }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM