Hi,

I may be wrong on understanding your question or need, but it sounds
like something I came across as well and wrote a plug-in solution.

Background:

The bottom line is the jQuery AJAX calls (.get, .load, etc) will use
an encoded url request and it issues ampersand (&) delimited key=value
(or name=value) pairs. lets call them NV pairs.  The final request is:

         url?parameters_in_nvpairs_format

example

        /someprogram?p1=v1&p2=v2


However, that is not what you pass for parameters for the
optional .get(,parameter) variable. It only access an JSON formatted
object or array.

      WRONG: -->  .get(url, "p1=v1&p2=v2");
      RIGHT-->  .get(url, {p1:"v1", p2:"v2"})';

If you pass NVpairs, believe it or not, jQuery will see the strng as
an array of characters and send a pair for each character in the
string using the index of the string as the name or key:

      0=p&1=1&2=%3D&3=v&4=1&5=%26&6=p&7=2&8=%3D&9=v&10=2

Solution:

I found this non support for passing a natural stirng of nvpairs  to
be a "obstrusive" design so I created a override plug-in for the base
method $.param() which handles this transformation.

(function($) {
  var _inherit = $.param;
  if ($.fn.jquery && $.fn.jquery <= "1.1.3.1") {
     $.param = function(a) {
         return (a.constructor == String)?a:_inherit(a);
     };
  }
})(jQuery);

This will allow you to send a string of nvpairs, an JSON object or
array.

Note, the (a.constructor == String) line.    Maybe that is all you
needed?  To detect the type of variable?

Not sure if this applies to you, but I hope it helps.

--
HLS


On Aug 21, 1:59 am, DocWyatt2001 <[EMAIL PROTECTED]> wrote:
> I'm writing some plugins/modules for JQuery and a PERL based CMS (yeah
> yeah, I know, PHP is simpler, etc, but its a long story, and I'm stuck
> with it), and I have a bit of a dilemma.
>
> I'm working on an implementation of JSON-RPC v1.1 using JQuery on the
> client side, and PERL on the server. I have the underlying preliminary
> code working - calls are being made, and responses generated and
> handled. I'm going back and doing the data validation and checking to
> make the system a little more robust.
>
> During the development, in the spec it says calls made using a GET can
> only be strings or arrays (which can be flattened into a string).
> Using $.ajax, I can see this happening happily. But I can also send it
> an object, which it translates in [object object].
>
> So the question is, how do I check for the existance of type Object on
> a variable - and it may not necessarily be at the top level. i.e.
> Array with an Object in that array somewhere. I just want to check for
> the existance of this condition quickly, not correct it.
>
> Any ideas?

Reply via email to