0

I'm currently attempting to perform an ajax request through jquery to fetch some data from a server. However, whenever calling $.ajax, it brings up this error.

enter image description here

The weird thing is, whenever calling $.ajax without any attributes, which should be valid, it still brings up the same error. I'm using the latest version of jquery, 3.1.1, and not using the slim build.

Thanks in advance.

My Ajax:

$.ajax({
    url: url,
    method: 'GET',
    mimeType: 'text/plain',
    success: function(url, status) {
        // on success
    },
    error: function(error, status) {
        // on error
    }
});
mashedpotats
  • 324
  • 2
  • 16

2 Answers2

0

Apologize for the inconvenience,

As it turned out, jquery 2.2.4 worked just fine. Appears that it might be the fact that I'm not quite up to date with the new versions.

mashedpotats
  • 324
  • 2
  • 16
0

If you still wish to use jQuery >= 3.0 then you will have to manage your errors differently.

The jqXHR object returned from jQuery.ajax() is a jQuery Deferred and has historically had three extra methods with names matching the arguments object of success, error, and complete. This often confused people who did not realize that the returned object should be treated like a Deferred. As of jQuery 3.0 these methods have been removed. As replacements, use the Deferred standard methods of done, fail, and always, or use the new then and catch methods for Promises/A+ compliance.

https://jquery.com/upgrade-guide/3.0/#breaking-change-special-case-deferred-methods-removed-from-jquery-ajax

And you can find more details concerning Deferred standard methods here: https://api.jquery.com/category/deferred-object/

You will find an example of usage for errors in this post: Throwing an Error in jQuery's Deferred object

Community
  • 1
  • 1
maxime_039
  • 464
  • 8
  • 14