duanhuihui2705 2016-05-04 10:35
浏览 50

jQuery Ajax成功提交条件问题

I have a form that I submit to a php file, the php file will check if the record exists or not. If it exists it will echo "Already Exists". In my ajax "success" it does see the "Already Exist" but when I place a condition it does not work. For example under success in my ajax function I placed the following

$.ajax({
    type: "GET",
    data: $('#minifrm').serialize(),
    url: "CRUD/myfile.php?check=" + para + "&freq=" + freq + "&expire=" + expire,
    success: function (status) {
        if (status.success == false) {
            alert("Your details we not saved");
        } else {
            var checkstatus = status.toString();

            if (checkstatus === 'Already Exists')
            {
                alert("You are here");
            }
            if (checkstatus === '')
            {
                alert("There is nothing");
            }
        }
    }
});

Currently it will echo "Already Exists" and alert "You are here" but if it doesn't exist it will not alert "There is nothing".

  • 写回答

2条回答 默认 最新

  • dongtang5776 2016-05-04 10:37
    关注

    Use double equal to == instead of single = for comparing two variable like this :

    if(checkstatus == 'Already Exists')
      {
        alert("You are here");  
      }
    
    评论

报告相同问题?

悬赏问题

  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?