简体   繁体   English

警报不适用于错误消息

[英]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. // Alert无法处理错误消息,之后我只想插入4个问题,因此它不起作用。

 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 . //这里(msg.success =='Error')不起作用,我想显示此消息-“请关闭上一个问题”。

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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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