.ajax fires both the error and success events
I'm very confused by an odd behaviour on my staging server.
I have this code:
- $('#pdf-link-exists').hide();
- $('#pdf-link-missing').hide();
- $.ajax({
- url: 'http://www.domain.com/theme/company-one/files/procedure_standard_1234567.pdf',
- type: 'HEAD',
- error: function(jqXHR, textStatus, errorThrown){
- $('#pdf-link-missing').show();
- },
- success: function(data, textStatus, jqXHR){
- $('#pdf-link-exists').show();
- }
- });
It should be checking to see if a files was created successfully, then showing the 'exists' link if it exists, or the 'missing' link if it does not exist. This works fine on my dev machines and the live server, so I think the code should be okay. But on the stagng server it is always showing both links.
I've tried commenting out lines to test what is happening and it is definately running the code, and firing both the success and error events.
I've checked the firebug console, and the ajax call is only appearing in there once.
Does anyone have any ideas how this could be happening?
Cheers
Mike