This if my first post here, so hello to everyone. I've only been doing AJAX development for about 6 months, so please bear with me.
I have a main "Dashboard" page with an AJAX div. I also have a button that launches a form in an iframe (powered by fancybox - basically just creates a CSS overlay). Currently, I have this in the body tag of the dashboard:
<body onLoad="Div1Request(); setInterval('Div1Request()',1000);">
It just fills the div when the page is first loaded, and then refreshes the div every second.
Once a form is submitted through the iframe, the last line of code just closes the CSS overlay/iframe:
My question is this: Is it somehow possible to only call Div1Request() after a form has been submitted, instead of checking every second for changes? I have tried running Div1Request() right before closing the iframe, but I think the issue I'm running into is that it's running Div1Request() IN the iframe, instead of on the dashboard.
I hope that makes sense to someone. I've been messing around with it for about two weeks now without any luck. This is sort of my last resort. If anyone thinks they could help, or can at least point me in the right direction I would really appreciate it. Thanks!
The developerWorks Connections platform will be sunset on December 31, 2019. On January 1, 2020, this forum will no longer be available. More details available on our FAQ.
Pinned topic Refresh an AJAX div upon form submission
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2011-03-27T02:21:18Z at 2011-03-27T02:21:18Z by SystemAdmin
sCOTTYgAV 270003YG8X4 Posts
Re: Refresh an AJAX div upon form submission2011-03-09T01:07:26ZThis is the accepted answer. This is the accepted answer.Dude! I wish i asked this question only 6 months in...
if i have it right...
you are using a form that has something like
form.target = 'myIFrame';
you can also use
form.setAttribute("action","myJSCleanUp");to do any other task.
I use this for uploading and refreshing pages ie
form.target, to save a pick on the server
form.setAttribute, to refresh the page with the newly uploaded pic
Sweet dreams punk!
SystemAdmin 110000D4XK1140 Posts
Re: Refresh an AJAX div upon form submission2011-03-27T02:21:18ZThis is the accepted answer. This is the accepted answer.Ok, i didn't give the correct answer above. I realized my mistake much later so here is the correct answer...
the trick is to manipulate the form's submit. I did it like this.
submit.onclick = new Function("savePick(this.parentNode)");//keep a reference to the form
_form.submit();//save the pick to the server...what ever your doing
window.setTimeout( requestLatestAddedImage, 10000);//now perform what ever after, I put in a delay before trying to download a pick, perhaps you could just call your method with out delay.
Hope I got it right this time.