Executing server code

Discussion in 'Javascript' started by titogarcia@gmail.com, Nov 18, 2005.

  1. Guest

    I want to execute server code invoked from inside Javascript code.

    I will have my server code in a servlet, callable with a URL, but how
    do I invoke the servlet from Javascript without reloading the page and
    not opening any window? I mean, I don't want to display the HTML result
    of this request.

    Regards,
    Ernesto
    , Nov 18, 2005
    #1
    1. Advertising

  2. VK Guest

    wrote:
    > invoke the servlet from Javascript without reloading the page and
    > not opening any window?


    >I mean, I don't want to display the HTML result
    > of this request.


    You don't need any JavaScript then: simply return

    HTTP/1.0 204 No content

    response from you servlet and user will stay on the current page.
    VK, Nov 18, 2005
    #2
    1. Advertising

  3. In article <>,
    says...
    > I want to execute server code invoked from inside Javascript code.
    >
    > I will have my server code in a servlet, callable with a URL, but how
    > do I invoke the servlet from Javascript without reloading the page and
    > not opening any window? I mean, I don't want to display the HTML result
    > of this request.


    Ajax.

    --

    Hywel
    http://kibo.org.uk/
    Hywel Jenkins, Nov 18, 2005
    #3
  4. David Wahler Guest

    VK wrote:
    > You don't need any JavaScript then: simply return
    >
    > HTTP/1.0 204 No content
    >
    > response from you servlet and user will stay on the current page.


    That's really interesting; I'd never heard of that response code
    before. I guess these days (with XMLHttpRequest being so popular) it's
    not such a big deal, but it's still nice to know about. Thanks!

    By the way, I know this is in the HTTP standard but are there any major
    browsers that don't support it? I've just tested with Firefox 1.0.6 and
    IE 6.0 and it works fine.

    -- David
    David Wahler, Nov 18, 2005
    #4
  5. VK Guest

    David Wahler wrote:
    > That's really interesting; I'd never heard of that response code
    > before. I guess these days (with XMLHttpRequest being so popular) it's
    > not such a big deal, but it's still nice to know about. Thanks!
    >
    > By the way, I know this is in the HTTP standard but are there any major
    > browsers that don't support it? I've just tested with Firefox 1.0.6 and
    > IE 6.0 and it works fine.


    HTTP/ ***1.0*** 204 No content

    This header is fully supported starting NCSA Mosaic and even earlier in
    Gopher prototypes.
    The only ever existed issue was with IE >= 5.1 && IE < 5.5 - on this
    platform one got hourglass coursor for the system timeout period
    (despite the page still did not change).

    I wrote an article here about this header but cannot google it out -
    that was some week, my head doesn't work. Anyway - the history of this
    header really needs to be described some day as a shining sample: how
    people do not see sometimes things which they need desperately - if
    such things are too close to their nose.

    This header existed *for years* before in late 90's one currently
    disappeared US-based online music CD store started to use it in their
    shoppping basket program. Competitors spyed for the trick, stole HTML
    codes(for no avail naturally) - and no one guessed to simply open damn
    public HTTP specs. :)

    Any way - use it with no fear... and roalty-free :)
    VK, Nov 18, 2005
    #5
  6. Randy Webb Guest

    Hywel Jenkins said the following on 11/18/2005 12:47 PM:

    > In article <>,
    > says...
    >
    >>I want to execute server code invoked from inside Javascript code.
    >>
    >>I will have my server code in a servlet, callable with a URL, but how
    >>do I invoke the servlet from Javascript without reloading the page and
    >>not opening any window? I mean, I don't want to display the HTML result
    >>of this request.

    >
    >
    > Ajax.
    >


    Why not something that is 100% compatible with any scriptable browser?

    document.images['someImage'].src="serverSideScriptToExecute.PHP";

    Now, no need to depend on ActiveX or native HTTPRequest support, only
    images collection and scripting.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
    Randy Webb, Nov 18, 2005
    #6
  7. VK Guest

    David Wahler wrote:
    > That's really interesting; I'd never heard of that response code
    > before. I guess these days (with XMLHttpRequest being so popular) it's
    > not such a big deal, but it's still nice to know about. Thanks!
    >
    > By the way, I know this is in the HTTP standard but are there any major
    > browsers that don't support it? I've just tested with Firefox 1.0.6 and
    > IE 6.0 and it works fine.


    HTTP/ ***1.0*** 204 No content

    This header is fully supported starting NCSA Mosaic and even earlier in
    Gopher prototypes.
    The only ever existed issue was with IE >= 5.1 && IE < 5.5 - on this
    platform one got hourglass coursor for the system timeout period
    (despite the page still did not change).

    I wrote an article here about this header but cannot google it out -
    that was some week, my head doesn't work. Anyway - the history of this
    header really needs to be described some day as a shining sample: how
    people do not see sometimes things which they need desperately - if
    such things are too close to their nose.

    This header existed *for years* before in late 90's one currently
    disappeared US-based online music CD store started to use it in their
    shoppping basket program. Competitors spyed for the trick, stole HTML
    codes(for no avail naturally) - and no one guessed to simply open damn
    public HTTP specs. :)

    Any way - use it with no fear... and roalty-free :)
    VK, Nov 18, 2005
    #7
  8. Thanks to all who answered.

    For now I think I will use XMLHttpRequest as I have todo it within
    Javascript and I am sure of the browser version that the clients will be
    using.

    Regards,
    Ernesto
    Ernesto García García, Nov 21, 2005
    #8
    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. John
    Replies:
    3
    Views:
    9,072
    Jacob Yang [MSFT]
    Nov 17, 2003
  2. Tim C.
    Replies:
    1
    Views:
    4,854
    Tommy
    Nov 27, 2003
  3. =?Utf-8?B?QXNoYQ==?=

    executing client side code from code behind.

    =?Utf-8?B?QXNoYQ==?=, Aug 12, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    591
    =?Utf-8?B?QWJL?=
    Aug 12, 2004
  4. Peri
    Replies:
    1
    Views:
    399
    Patrick Olurotimi Ige
    Jun 13, 2005
  5. -
    Replies:
    2
    Views:
    395
    Alan Krueger
    Jul 29, 2005
Loading...

Share This Page