Php jqueryajax';警觉

Php jqueryajax';警觉,php,jquery,ajax,echo,alert,Php,Jquery,Ajax,Echo,Alert,我有多个具有以下相同格式的函数: function xxx $.ajax({ type: "POST", url: "orders.php", data: {"error":"0","type": "inform","result4": $orderid}, dataType: 'json', success: function(data) { if (data.error != 0) {

我有多个具有以下相同格式的函数:

function xxx
    $.ajax({
        type: "POST", 
        url: "orders.php",
        data: {"error":"0","type": "inform","result4": $orderid},
        dataType: 'json', 
        success: function(data) {
        if (data.error != 0) {
            // An error occurred on server: do something 
        } else {
            Alert("Informed");
        }
    }
    });

    }
我调用的另一个PHP文件将返回以下内容:

echo json_encode(array("error"=>0, "result4"=>"Pass"));
1) 我如何让它显示警报,它不想运行警报


2) 如何在运行时在每一个屏幕上显示加载GIF加载?

使用
alert
而不是
alert

您可以将其作为jquery的一部分来显示loading.gif

$(document).ajaxStart(function() {
   $("#loading").show();
});

其中loading是带有
loading.gif的元素

我认为它的键入警报=>警报

此外,函数应在函数xxx中具有
()

php
json编码后返回