JQuery help

Discussion in 'ASP .Net' started by SAL, Sep 2, 2010.

  1. SAL

    SAL Guest

    Hello,
    I'm needing some help with JQuery as I'm brand new to this. I have googled
    and googled and the following is the best examples I can come up with. I
    have tried using JSON's stringify but an error occurs running out of memory.

    I have a gridview with a template field. In the template field there is a
    checkbox. I have declared onclick="chkHelp(this);" in the checkbox.

    In the javascript chkHelp, I call the following javascript function:
    function chkAdd(objRef) {
    // objRef is an ASP.NET checkbox who's parent is a gridviewrow who's
    parent is a gridview. These
    // resolve correctly.
    var gvr = objRef.parentNode.parentNode;
    var gv = gvr.parentNode;

    CallPageMethod("DoCheckbox", success, fail,
    "obj", objRef,
    "gv", gv,
    "gvrow", gvr);
    }

    In the CallPageMethod javascript function, I do the following:

    function CallPageMethod(methodName, onSuccess, onFail) {
    var args = '';
    var l = arguments.length;

    if (l > 3) {
    for (var i = 3; i < l - 1; i += 2) {
    if (args.length != 0) args += ',';
    args += '"' + arguments + '":"' + arguments[i + 1] + '"';
    }
    }

    var loc = window.location.href;
    loc = (loc.substr(loc.length - 1, 1) == "/") ? loc +
    "OwnerLinkPossEditor.aspx" : loc;

    $.ajax({
    type: "POST",
    url: loc + "/" + methodName,
    data: "{" + args + "}", //"{" + args + "}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: onSuccess,
    fail: onFail
    });
    }

    The page method is getting called correctly but the objects that get passed
    are strings and I can't convert them to the correct object types.
    I have tried removing the quotes around the objects but then the page method
    does even get called. Can somebody help me with how to pass the objects
    correctly to the page method?

    Needing help ASAP as I've been working on this for a bit now. Thanks

    SAL
    SAL, Sep 2, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Maghen

    JQuery Integration Help

    Alex Maghen, Dec 31, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    385
    Allen Chen [MSFT]
    Jan 5, 2009
  2. hedgehog
    Replies:
    1
    Views:
    144
    hedgehog
    Apr 6, 2007
  3. Big Moxy
    Replies:
    1
    Views:
    260
    Peter Michaux
    Dec 22, 2007
  4. Aaron Gray
    Replies:
    20
    Views:
    394
    Lasse Reichstein Nielsen
    Jul 27, 2008
  5. lorlarz
    Replies:
    6
    Views:
    213
    David Mark
    Mar 25, 2010
Loading...

Share This Page