1

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']);
    }
}); 
6
  • 2
    Have you added jQuery to the page. This will not work without jQuery. Commented Mar 25, 2014 at 11:12
  • just do console.log(data); and check does error repeat. Commented Mar 25, 2014 at 11:13
  • Console.log in success? It doesn't log because it gives this typerror. Commented Mar 25, 2014 at 11:15
  • 1
    I guess he has added jquery, or else this notice would,nt had been shown. args.concat is inbuilt in jquery.js library Commented Mar 25, 2014 at 11:16
  • Oh, seems that this happens on just some of the pages. If I do it front page it works perfectly. Perhaps some conflict with query on some pages. Commented Mar 25, 2014 at 11:19

3 Answers 3

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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']);
    }
  }); 
});

Comments

0

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']);
    }
}); 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.