This is my function to call ajax:
var sendAjax = function(type, data, callback) {
$.ajax({
url: homepage + 'server_ajax.php',
type: 'POST',
data: {
type: type,
data: JSON.stringify(data)
}
}).done(function(data) {
console.log(data);
callback(true, JSON.parse(data));
}).fail(function() {
console.log('NO');
callback(false, {});
});
};
Variable
homepage
contains valid URL. It is same domain, so this is not the problem.My
server_ajax.php
has only this:echo "awdawda wawddawawd";
- nothing more (testing purposes).I tried to put breakpoints to
$.ajax...
and to the console logs. First breakpoint works, but functionsdone
andfail
never run.No error show up in the browser console
My jQuery is include (I'm sure), I use
require.js
and everything else in this JS file using jQuery works well.I also tried change URL to something invalid (like
server_ajax2.php
) and console prints error 404 - like it would.Also tried with
dataType: 'json'
or removingdata
object...
Any ideas, what should I try? I also tried some answers on this site (don'r flag this as duplicate, I tried like everything), but nothing helped me.