'$.ajax success function won't show in the console when I do console.log(data);

In the $.ajax function I have the function for success like this:

success: function(data) {
    console.log(data);
},

but when I use the $.ajax function, it won't show anything in the console. If I use the $.post function and THEN I console.log(data), it WILL show up in the console, however it won't work because I can't have processData: false in the $.post function.

This is my entire $.ajax function:

$.ajax({
    url: 'post',
    type: 'POST',
    processData: false,
    contentType: false,
    cache: false,
    dataType: 'json',
    data: formData,
    success: function(data) {
        console.log(data);
    },
    error: function() {}
});


Solution 1:[1]

Slightly altering your code to run in jsfiddle, I don't see any problems (I get Success! Object {}):

var formData = {test: 'test'};

$.ajax({
    url: '/echo/json',
    type: 'POST',
    processData: false,
    contentType: false,
    cache: false,
    dataType: 'json',
    data: formData,
    success: function(data) {
        console.log('Success!', data);
    },
    error: function(e) {
        console.log('Error!', e);
    }
});

http://jsfiddle.net/zta6ugyw/

I suspect it's your URL. Watch Network tab in console to see if your server is returning a 404 or some other error.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jared Farrish