【前端_js】ajax的应用

1.设置请求头部

function makeRequest() {
    alert("inside makeRequest()");
    var settings = {
        type: "GET",
        url:URL+"?"+REQUEST,
        dataType:"xml",
        error: function(XHR,textStatus,errorThrown) {
            alert ("XHR="+XHR+"
textStatus="+textStatus+"
errorThrown=" + errorThrown);
        },
        success: function(data,textStatus) {
            $("body").append(data);
        },
        headers: {
            "Access-Control-Allow-Origin":"http://example.edu",
            "Access-Control-Allow-Headers":"X-Requested-With"
        }
    };
    $.ajax(settings);
}

2.ajax参数详解:Ajax最详细的参数解析和场景应用

3.ajax请求错误调试分析:jQuery中ajax错误调试分析

4.JQuery中$.get、$.post、$.getJSON、$.ajax 方法详解

 

原文地址:https://www.cnblogs.com/leiblog/p/10951858.html