Solved

Refresh page using ajax

Posted on 2008-10-09
9
2,138 Views
Last Modified: 2012-05-05
Dear all,

I have a qn on how I can set it to refresh the page. Ajax doesn't do the refresh and awaits it to load. That's what I want.

However, on the main page, I have an iframe containing a page called pms_list.asp.
Upon clicking the item name in the list, another window will show up in this popup window page called maint_main.asp. If i want to submit a new record to the list, I will have to click a button on maint_main.asp and redirect to maint_new.asp.

Now if i submit maint_new.asp with the records inserted, how do I refresh the pms_list.asp which is not the parent page at all?

Anyone can help me with this asap?

0
Comment
Question by:Yannie
9 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 22682473
The script to refresh the parent of the iframe is this:

 onClick="opener.parent.location.reload(true);"

But that will not help because the onClick will do the refresh imideately on link click not after the update was done on server side.
So your response to the link click should contain the refresh() call like this:
<script>opener.parent.location.reload(true);</script>

Send that snippet after update on server side to the popup and the iframe container page will be reloaded.


0
 
LVL 14

Expert Comment

by:ziffgone
ID: 22682728
Actually, it should be this:

<script type="text/javascript">
window.opener.frames['PMS_LIST_IFRAME_NAME_HERE'].location.reload(true);
</script>

Output the above script from the page called from your AJAX that updates the list database.

Regards...
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 22684505

Please remember that pasting responseText into a div using innerHTML will NOT execute any script.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:Yannie
ID: 22699806
Actually

<script>opener.parent.location.reload(true);</script>

refreshes but i will have to wait for th page to refresh done.
I tot Ajax refreshes it alot faster and doesnt show obvious refresh in the background
0
 

Author Comment

by:Yannie
ID: 22699809
Actually

<script>opener.parent.location.reload(true);</script>

refreshes but i will have to wait for th page to refresh done.
I tot Ajax refreshes it alot faster and doesnt show obvious refresh in the background
0
 
LVL 14

Accepted Solution

by:
ziffgone earned 500 total points
ID: 22700119
Yannie,

Instead of using an iframe, use a DIV element, (If you want it to act like an iframe, set the CSS overflow to auto and set your maximum height and width. You can then instantly refresh this content in the DIV with AJAX.:

<div id="pms_list" style="overflow:auto;width:500px;height:300px;">
<!--#include file="pms_list.asp"-->
</div>

Then update the DIV with your AJAX when your button is clicked. Example:

if(xmlHttp.readyState==4) {
      document.getElementById('pms_list").innerHTML=xmlHttp.responseText;
}

Hope this makes sense.

Regards...
0
 

Author Comment

by:Yannie
ID: 23390158
OK thank you very much. Managed to get it solved in my own...thank you..
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Converting dates in JavaScript 2 35
Select record with the most recent date 14 56
PHP AJAX JSON 2 61
Help with removing item from Session Array 3 24
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

777 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