CORS synchronous requests not working in firefox

前端 未结 1 2024
挽巷
挽巷 2021-02-05 21:54

The official documentation of jQuery ( async ajax section ) says that:

Cross-domain requests and dataType: \"jsonp\" requests do not support synchronou

1条回答
  •  北海茫月
    2021-02-05 22:28

    Use beforeSend instead of xhrField.

    $.ajax({
        type : "GET",
        async: false,
        dataType : "text",
        url : link,
        beforeSend: function(xhr) {
          xhr.withCredentials = true;
        },
        success: function(response){
          console.log("success ");
        },
        error: function(error){
          console.error(error);               
        }
    });
    

    0 讨论(0)
提交回复
热议问题