在ajax成功括号内显示对话框时出现问题

Having Issue in showing dialog box inside ajax success bracket

本文关键字:对话框 问题 显示 ajax 成功      更新时间:2023-09-26

我有一个问题,在我的ajax脚本它不会显示对话框后ajax成功,如果我把datatype: 'json'和如果我删除dataType: 'json'对话框显示弹出后ajax成功。

我的脚本只显示我的对话框,如果我删除数据类型。

$('#OppaForm').ajaxSubmit({ 
        type: "POST",
        url: "Oppa/view/editOther.php",
        data: $('#OppaForm').serialize(),
        cache: false,
        success: function (response) {
          $("#dialog-confirm-updateOther").dialog("open");
    }
});

我有一个ajax脚本,显示对话框,即使数据类型存在。

$('#OppaForm').ajaxSubmit({ 
type: "POST",
url: "Oppa/view/photo.php",
dataType: "JSON",
data: $('#OppaForm').serialize(),
cache: false,
success: function (response) {
if (Number(response) == 1)
    {
       $("#dialog-confirm-changedImage").dialog("open");
       $('#imageInput').replaceWith($('#imageInput').val('').clone(true));
    }
    }
});
if (Number(response) == 1)

这一行会引起问题,因为如果您需要数据类型json,响应将不是1你不能这样比较

你需要遍历json内容