Topic
  • 4 replies
  • Latest Post - ‏2014-09-20T12:06:24Z by jitupkp
Sakada
Sakada
1 Post

Pinned topic Refresh an AJAX div upon form submission

‏2011-03-02T20:48:37Z |
Hey everyone,

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:

<script type="text/javascript">parent.jQuery.fancybox.close();</script>

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!

-Sakada
Updated on 2011-03-27T02:21:18Z at 2011-03-27T02:21:18Z by SystemAdmin
  • sCOTTYgAV
    sCOTTYgAV
    4 Posts

    Re: Refresh an AJAX div upon form submission

    ‏2011-03-09T01:07:26Z  
    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.setAttribute("target", "myIFrame");
    or
    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
    SystemAdmin
    1140 Posts

    Re: Refresh an AJAX div upon form submission

    ‏2011-03-27T02:21:18Z  
    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
    function savePick(_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.
    Scott
  • jitupkp
    jitupkp
    104 Posts

    Re: Refresh an AJAX div upon form submission

    ‏2014-09-20T12:06:12Z  

    see more

    http://techgurulab.com/course/ajax-quiz-online/

  • jitupkp
    jitupkp
    104 Posts

    Re: Refresh an AJAX div upon form submission

    ‏2014-09-20T12:06:24Z  
    • sCOTTYgAV
    • ‏2011-03-09T01:07:26Z
    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.setAttribute("target", "myIFrame");
    or
    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!

    see more

    http://techgurulab.com/course/ajax-quiz-online/