Skip to main content

Bug Tracker

Side navigation

#12783 closed bug (invalid)

Opened October 23, 2012 07:29AM UTC

Closed November 07, 2012 08:53AM UTC

using $.ajaxPrefilter with CORS request

Reported by: rosko+jquery@mindsys.org Owned by: rosko+jquery@mindsys.org
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.2
Keywords: Cc:
Blocked by: Blocking:
Description

Using $.ajaxPrefilter in Cross-origin resource sharing leads to 'parsererror'.

I'm using ajaxPrefilter to prepend server address to url before firing request. Request is send to proper url (as expected) but parser fails with textStatus 'parsererror' and errorThrown 'No conversion from json to domain.name/api/url (this is the full URL that is requested).

Here's how to reproduce:

$.ajaxPrefilter(function( options, originalOptions, jqXHR ){
  options.url = 'http://updates.html5rocks.com' + options.url;
});

$.ajax({
  type: 'GET',
  url: '/2012/09/Live-Web-Audio-Input-Enabled',
  success: function() {
    console.log('success');
  },
  error: function(jqXHR, textStatus, errorThrown) {
    console.log('textStatus: ' + textStatus);
    console.log('errorThrown: ' + errorThrown);
  }
});
Attachments (0)
Change History (3)

Changed October 23, 2012 11:09AM UTC by jaubourg comment:1

Could you provide a reduced test case for this? Not a jsfiddle since "Origin http://fiddle.jshell.net is not allowed by Access-Control-Allow-Origin.", but a simplified example on your server.

From what I can guess, you most probably set the dataType option of the request to "domain.name/api/url" somewhere. So there's something going on outside of this prefilter or the prefilter is more complex than what you put here.

Changed October 23, 2012 12:24PM UTC by mikesherov comment:2

owner: → rosko+jquery@mindsys.org
status: newpending

Changed November 07, 2012 08:53AM UTC by trac-o-bot comment:3

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!