Skip to main content
WolfShade
Legend
May 24, 2011
Answered

Get JavaScript to pass NULL to CF in a way CF understands

  • May 24, 2011
  • 2 replies
  • 1490 views

Is there a way for JavaScript to pass NULL to CF9 in a way CF9 understands?

null didn't work; neither did undefined.

^_^

    This topic has been closed for replies.
    Correct answer ilssac

    WolfShade wrote:

    CFAJAXPROXY is giving JavaScript access to a CFC called "query.cfc":

    IT IS VERY VERY VERY important to understand that CFAJAXPROXY is just a wrapper|wizard to creating JavaScript xmlHttpRequest object and response handlers

    The xmlHttpRequest object is just a wrapper to create a normal HTTP request that is no different then if you click a link or submit a form.  It is just done in the background of the browser.

    WolfShade wrote:

    z.setHTTPMethod("POST");

    In other words.  You are submitting a form (aka post) HTTP request.  Now have you ever submitted an HTML form with a NULL field?  I never have.  The best you can get is an empty string.  Which is pretty much all ColdFusion knows as a NULL value, though CF 9 is a tiny bit smarter about NULLS then earlier editions.

    2 replies

    BKBK
    Community Expert
    Community Expert
    May 24, 2011

    WolfShade wrote:

    Is there a way for JavaScript to pass NULL to CF9 in a way CF9 understands?

    There isn't. The concept/value NULL in Javascript has no equivalent in ColdFusion. Perhaps more important, Javascript runs on the browser and ColdFusion on the server. So Javascript cannot just "pass" values as-is to ColdFusion.  If it could, a visitor to your site could write a cheque to himself and sign it with your signature.

    ilssac
    Inspiring
    May 24, 2011

    I can't imagine a way.  HOW are you "passing" a JavaScript value to ColdFusion?  There is no direct connection between the JavaScript system and the ColdFusion system.  The only communication between the two is HTTP posts and requests.  As Far As I Know, there is no specification for NULL in the HTTP protocol.

    WolfShade
    WolfShadeAuthor
    Legend
    May 24, 2011

    CFAJAXPROXY is giving JavaScript access to a CFC called "query.cfc":

    z = new cfc_query();

    z.setHTTPMethod("POST");

    I can access a method called "doThis" like so:

    z.doThis(parameters);

    If "doThis" were a query that updates a table that allows NULLS if the value passed to it is NULL,

    how do I get JavaScript to say to ColdFusion, "This value is NULL"?

    null doesn't do it; nor does undefined.

    ^_^

    ilssac
    ilssacCorrect answer
    Inspiring
    May 24, 2011

    WolfShade wrote:

    CFAJAXPROXY is giving JavaScript access to a CFC called "query.cfc":

    IT IS VERY VERY VERY important to understand that CFAJAXPROXY is just a wrapper|wizard to creating JavaScript xmlHttpRequest object and response handlers

    The xmlHttpRequest object is just a wrapper to create a normal HTTP request that is no different then if you click a link or submit a form.  It is just done in the background of the browser.

    WolfShade wrote:

    z.setHTTPMethod("POST");

    In other words.  You are submitting a form (aka post) HTTP request.  Now have you ever submitted an HTML form with a NULL field?  I never have.  The best you can get is an empty string.  Which is pretty much all ColdFusion knows as a NULL value, though CF 9 is a tiny bit smarter about NULLS then earlier editions.