$.get sends prototype functions in request URL?

Posted by pimvdb on Stack Overflow See other posts from Stack Overflow or by pimvdb
Published on 2011-01-29T23:15:10Z Indexed on 2011/01/29 23:26 UTC
Read the original article Hit count: 211

Filed under:
|
|

I have some prototype functions added to Object which in my opinion were practical in certain scenarios. However, I noticed that when I executed a $.get, the prototype functions are handled as data members and are sent like http://...?prototypefunc=false.

This is rather useless as I don't supply these as data members, but they are added to the query string.

To be exact, I have this code:

Object.prototype.in = function() {
    for(var i=0; i<arguments.length; i++)
       if(arguments[i] == this) return true;
    return false;
}

$.get('http://localhost/test.php', {'test': 'foo'}, function(text) { });

The corresponding URL constructed is:

http://localhost/test.php?test=foo&in=false

How can I avoid this?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery