Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Executing server code

Reply
Thread Tools

Executing server code

 
 
titogarcia@gmail.com
Guest
Posts: n/a
 
      11-18-2005
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

 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      11-18-2005

http://www.velocityreviews.com/forums/(E-Mail Removed) 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.

 
Reply With Quote
 
 
 
 
Hywel Jenkins
Guest
Posts: n/a
 
      11-18-2005
In article <(E-Mail Removed) .com>,
(E-Mail Removed) 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/
 
Reply With Quote
 
David Wahler
Guest
Posts: n/a
 
      11-18-2005
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

 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      11-18-2005

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

 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      11-18-2005
Hywel Jenkins said the following on 11/18/2005 12:47 PM:

> In article <(E-Mail Removed) .com>,
> (E-Mail Removed) 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/
 
Reply With Quote
 
VK
Guest
Posts: n/a
 
      11-18-2005

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

 
Reply With Quote
 
Ernesto García García
Guest
Posts: n/a
 
      11-21-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sample code for Connecting and Executing a stored procedure is SQL server using ASP.NET Peri ASP .Net 1 06-13-2005 04:56 AM
how do I make the validator cut off other code on the page from executing? bennett@peacefire.org ASP .Net 1 06-02-2005 04:25 PM
Having a problem using WebRequest inside code invoked by the Page_Load event to to download a page located on same server (as the currently executing page). Hasani \(remove nospam from address\) ASP .Net 9 09-29-2004 05:07 PM
executing client side code from code behind. =?Utf-8?B?QXNoYQ==?= ASP .Net 1 08-12-2004 06:15 AM
Session end event fires but it is not executing code Sampriti ASP .Net 4 06-26-2003 10:54 PM



Advertisments