Please help test a CORS issue in Firefox jQuery ajax when 401

后端 未结 4 1650
野的像风
野的像风 2021-01-03 01:10

this is driving me nutters.

jQuery 1.4.2, windows XP sp3

Here is my test.

Load firefox 3.5+

http://plungjan.name/test/testcors.html

w

4条回答
  •  我在风中等你
    2021-01-03 02:00

    So you need to set an ajax prefilter in your model/collection in order to use CORS. Otherwise it doesn't send the cookie.

    $.ajaxPrefilter( function( options, originalOptions, jqXHR ) {
        options.xhrFields = {
          withCredentials: true
        };
    });
    

    I put this in my Model/Collection initialize function.

提交回复
热议问题