Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

post without reply

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
kapitany
Asked:
kapitany
  • 5
  • 5
  • 3
  • +1
1 Solution
 
hkmdjCommented:
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
 
kapitanyAuthor Commented:
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
 
hkmdjCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
CJ_SCommented:
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
 
kapitanyAuthor Commented:
hidden frame is a good Idea I will make a try :-)
0
 
CJ_SCommented:
Good luck, just remember to set the target for when you click on a link, or whatever.

CJ
0
 
kapitanyAuthor Commented:
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
 
CJ_SCommented:
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
 
knightEknightCommented:
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
 
knightEknightCommented:
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
 
kapitanyAuthor Commented:
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
 
CJ_SCommented:
KnightEKnight, that is what I suggested to send some data back, DOH.....
0
 
knightEknightCommented:
DOH!  I didn't see that either.  However, it was the other suggestion that finally worked for him.
0
 
CJ_SCommented:
KnightEKnight....well, that's cool =)....
0
 
kapitanyAuthor Commented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 5
  • 5
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now