Solved

post without reply

Posted on 2000-05-01
15
200 Views
Last Modified: 2010-04-09
Hi,

Is there a way to send data to the server without getting a new page? I would like to send if the checkbox was set or not and store in my java servlet. But I haven't found the way how to post without getting a reply or at least waiting a reply from the server.
Thanx
0
Comment
Question by:kapitany
  • 5
  • 5
  • 3
  • +1
15 Comments
 
LVL 1

Expert Comment

by:hkmdj
ID: 2765605
You can post to the same page you have loaded. It still posts through, but may be faster because the page items are cached.  just change action to be the name of your current page and include any code you need on that page.

dj
0
 

Author Comment

by:kapitany
ID: 2765624
Yes it might work but I don't want to reload the page even if it's cached.  I just want to post the state of a checkbox if it was changed and storing the checkbox state immediately. The state might be used in other windows as well. So how can I do a data sending to the server without any reply?? or frame reload...
kapitany
0
 
LVL 1

Expert Comment

by:hkmdj
ID: 2765636
well, you kind of condemned yourself in wanting to 'post the state of a checkbox'.  Somethings got to give if you want to post.  Standard HTML is probably not going to do it for you.  If you are running Java Servlets or ASP or something, then you may be able to add a component or a control to perform this action.  the component would have to download with the first retrieval of the page and be running on the users machine while browsing that page, then it could communicate if the box was changed, but this is huge.  

The bigger question is why don't you want the page to reload? Is there something that is occuring that you need to stop?  maybe there is another way to attack this.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:CJ_S
ID: 2765652
you could use a hidden frame which doesn't get any data or just a few bytes so you know that it reahced the server or sumthing....
0
 

Author Comment

by:kapitany
ID: 2765664
hidden frame is a good Idea I will make a try :-)
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2765720
Good luck, just remember to set the target for when you click on a link, or whatever.

CJ
0
 

Author Comment

by:kapitany
ID: 2765738
Sorry but seems to be not the right solution. The problem is that it again stops the user to do anythinkk in the browser because it makes to wait util the reply arrives... So the user is stocked.. :-(  Isn't there a simple way just to send data without expecting any answer??
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2765792
Nope, you will always receive a reply. How about opening a new window, and closing it right away? Makes the current browser still viewable, and the new window will hafta wait.

CJ
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2766165
CJ_S, I think you were right to suggest a hidden frame -- the trick is to return something to that frame.  If no reply is sent, then the frame will wait forever.  kap, why don't you just return a small dummy page to the hidden frame each time?  Like this:

<HTML></html>
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 10 total points
ID: 2766178
Or, if you don't want to return anything to the hidden frame, then open the hidden frame with this file:

<HTML>
<HEAD>
<SCRIPT language='javascript'>
function stopme()
{
   self.stop();
   setTimeout("stopme()",500);
}
</script>
</head>
<BODY onLoad="stopme();">
</body>
</html>

I don't know for sure, but the theory is that the hidden frame will continuously "stop" checking for returning data.  Just a thought.
0
 

Author Comment

by:kapitany
ID: 2766504
There is a little problem. The whole stuff seems to be working fine with the hidden frame. The only problem is that the target="hiddenframe" don't works when I'm using the onclick="this.form.submit()" method. It loads in the same frame from where the submit was done. I tried with a submit button it worked fine, but when I try with this onclick submit it don't works.
THIS DON'T WORKS:
<form name="noname" method="post" action="../servlets/AddBag" target="hiddenFrame">
<input type="hidden" name="name" value="Monopoly">
<input type="checkbox" name="checkbox" onClick="this.form.submit()">
</form>

THIS WORKS:
<form name="noname" method="post" action="../servlets/AddBag" target="hiddenFrame">
<input type="hidden" name="name" value="Monopoly">
<input type="checkbox" name="checkbox" onClick="this.form.submit()">
<input type="submit" name="Submit" value="Submit">
</form>

WOWW!
I just replaced the input type with "hidden" and it works fine!!!
So an other input stuff was needed.. But why ...
But the point that it works now!:-)

THANKS :-)))
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2766552
KnightEKnight, that is what I suggested to send some data back, DOH.....
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 2766660
DOH!  I didn't see that either.  However, it was the other suggestion that finally worked for him.
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2766711
KnightEKnight....well, that's cool =)....
0
 

Author Comment

by:kapitany
ID: 2766752
Hi,

YEPP really cool :-)
Just one thing. I figured out that if I change  in the NON WORKING example the input order which means
<input type="checkbox" name="checkbox" onClick="this.form.submit()">
<input type="hidden" name="name" value="Monopoly">

then it works fine. Maybe this.form.submit() just sends what is coming after and don't cares what was before :-)))

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to create a table with buttons 3 31
html / css issue / div issue. stuck, help needed 2 23
Non-Resizable Pharagraph 2 18
Add a little space on either side of a table. 12 25
Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question