Reputation: 355
I have simple Ajax request, but for some reason it gives some error. I don't have a clue what this error means:
TypeError: Object function bound(var_args) { return func.apply(thisObject, args.concat(slice(arguments))); } has no method 'ajax'
It's trying to access PHP function where it gets data.
Here is the ajax request itself:
$.ajax({
type: 'POST',
url: 'http://me.mydomain.com/get-ajax.php',
data: {
'action': 'request',
'id': 314
},
dataType: 'json',
success: function(data) {
console.log(data['post']);
}
});
Upvotes: 1
Views: 191
Reputation: 1166
I guess your jquery is conflicting. try-
$m=jQuery.noConflict(); // write it at the top
$m.ajax({
type: 'POST',
url: 'http://me.mydomain.com/get-ajax.php',
data: {
'action': 'request',
'id': 314
},
dataType: 'json',
success: function(data) {
console.log(data['post']);
}
});
Upvotes: 0
Reputation: 1651
Make sure your jQuery script is loaded when you make this ajax call, as @mesutozer said, if that doesn't help then I assume you have some additional javascript that could be using $ shortcut so try jQuery.ajax({...}) instead
Upvotes: 1
Reputation: 2859
Enclose your $.ajax call within jQuery's document ready callback to make sure it is executed when jQuery is loaded
$(document).ready(function (){
$.ajax({
type: 'POST',
url: 'http://me.mydomain.com/get-ajax.php',
data: {
'action': 'request',
'id': 314
},
dataType: 'json',
success: function(data) {
console.log(data['post']);
}
});
});
Upvotes: 0