• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

window.location.replace

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
consider the following java script function written in a jsp file using struts framework.

function doDone()
{
var thisForm = document.forms[0];
thisForm.action = '/find.sn?dispatchMethod=find';
thisForm.submit();
}

if i change it with as follows

function doDone()
{
var outUrl;
outUrl = '/find.sn?dispatchMethod=find';
window.location.replace(outUrl);
}

why the latter one not result in submission of values of corresponding fields whose match is there in form bean of that action? please clarify.
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never used window.location.replace but I think its a good bet that it doesn't submit the current form, it just sends the specified URL to the server. This seems especially likely because there is no code in the second function to indicate what form you would be submitting.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's correct; a location.replace wouldn't submit the form!

Dave
 
Sreejith kayappuram
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
k. Thnaks for the reply.
so can i say like submit will invoke post method and location.replace invoke get method in servlet concept.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You *could* say that, but it's not always true: a form submit will submit with whatever method the form tag defines, which may be GET or POST.

Dave
 
Sreejith kayappuram
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yea.

Thanks for the information.
 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic