且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

jQuery'If'语句字符串比较不工作

更新时间:2023-11-15 18:11:10

您可以使用 $。trim() 如下:

You can fix it on the client side using $.trim() like this:

if($.trim(data) == 'success') {

线来自服务器端,可能是您的PHP中某个错误的新行,检查<?之前或之后

Or, a better approach would be removing the new-line coming from the server-side, probably an erroneous new-line in your PHP somewhere, check before or after the <? ?> block, this is most often where they crop up.

或者,在输出内容后退出,如下所示:

Or, just exit after outputting your content, like this:

if($update) {
  echo 'success';
  exit();
}