JSON response from jQuery get raises “Invalid label”

后端 未结 6 1212
日久生厌
日久生厌 2020-12-20 07:10
       $.ajax({
  beforeSend: function(xhr) {
 xhr.setRequestHeader(\'Authorization\', \"Basic YWRtaW46YWRtaW4=\");        
},
   url: \"https://test.com/incident.do         


        
6条回答
  •  清酒与你
    2020-12-20 07:33

    If you are using 1.5.2 (and maybe older versions), you can disable jsonp if you do not need it or want it.

    So for all ajax calls add this somewhere on your page:

    $.ajaxSetup({
        jsonp: null,
        jsonpCallback: null
    });
    

    Or for just one call, add this:

    jsonp: null,
    jsonpCallback: null,
    

    So in your example:

    $.ajax({
        beforeSend: function(xhr) {
            xhr.setRequestHeader('Authorization', "Basic YWRtaW46YWRtaW4=");        
        },
        url: "https://test.com/incident.do?JSON&callback=?&sysparm_action=getRecords",
        dataType: "json",
        contentType: "application/json",
        method: 'GET',
        jsonp: null,
        jsonpCallback: null,
        success: function(a,b,c) { 
            alert(a);
        }          
    });
    

提交回复
热议问题