• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Ajax Call back to Calling window.

Hi:

I have a.Net 3.5  application that launches a new window that makes some calls to a web service and updates my database.

The call comes from a hyperlink on a grid and the javascript looks like this:

 
<script type="text/javascript">
     function openRadWindow(ModuleUrl)
     var oWnd = window.open(ModuleUrl)
     ...

Open in new window


When that window closes, I would like to run a procedure on the server side that essentially refreshes the grid from which the window was originally launched. (myGrid.ReBind())

Can someone help me to figure out how to make such a call on the server side when the window closes?

Any help appreciated.
RBS
0
RBS
Asked:
RBS
  • 2
2 Solutions
 
strickddCommented:
When you open the child window, call the function below:

function check() {
  if (oWnd .closed) {
    // either set the location of the window to redirect back to the same page and force a refresh, or make an AJAX call to re-populate the grid.
  } else setTimeout("check()",1);
}

Open in new window

0
 
PryratesCommented:
You can try something like that - works fine in FF and Safari:

popup.html:
 
<html>
<head>
<script language="JavaScript">

function closeWindow()
{
	window.close();
}

function OnClose()
{
	window.opener.writeTime('closed popup');
}
</script>
</head>
<body onunload="Javascript:OnClose();">
<a href="JavaScript:closeWindow();void(0);">window close</a>
</body>

Open in new window


index.html
 
<html>
<head>
<script language="JavaScript">
var wnd;
function openWindow()
{
	wnd = window.open("popup.html");
}

function writeTime(action)
{
	var t = document.getElementById("time");
	t.innerHTML +="<br />" + action + " " + (new Date()).getTime();
}
</script>
</head>
<body onload="JavaScript:writeTime('loaded')">
<a href="JavaScript:openWindow();void(0);">window open</a>
<br /><span id="time"></span>
</body>
</html>

Open in new window

0
 
PryratesCommented:
In the writetime method in the sample-page above you can place your ajax-call to rebind the grid / refresh the page.
The sample only demonstrates how to get the close event of a popup you opened.
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now