Opened 10 years ago
Closed 10 years ago
#12783 closed bug (invalid)
using $.ajaxPrefilter with CORS request
Reported by: | Owned by: | ||
---|---|---|---|
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); } });
Change History (3)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
Owner: | set to [email protected]… |
---|---|
Status: | new → pending |
comment:3 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | pending → closed |
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!
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.