public string keepinvoke()
3 {
4 Thread.Sleep(3000);
5 return "<script language='javascript' type='text/javascript'>parent.push('.NET PUSHLET')</script>";
3 {
4 Thread.Sleep(3000);
5 return "<script language='javascript' type='text/javascript'>parent.push('.NET PUSHLET')</script>";
6 }
content.aspx:
1 <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
2 <%@ Import Namespace="System.Threading"%>
3
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6 <html xmlns="http://www.w3.org/1999/xhtml" >
7 <head runat="server">
8 <title>content</title>
9 <script language="javascript" type="text/javascript" src="http://www.cnblogs.com/Scripts/jquery-1.3.2.js"></script>
10 </head>
11 <body style="background-color:#AAAAAA;">
12 <script language="javascript" type="text/javascript">
13 $(document).ready(function() {
14 setInterval(invoke, 3000);
15 });
16 function invoke() {
17 var xhr = $.ajax({
18 type: "POST",
19 url: "/Home/keepinvoke",
20 data: "",
21 success: function() {
22 var jsonstr = xhr.responseText;
23 $(jsonstr).appendTo("body");
24 }
25 });
26 }
27 </script>
28 <div></div>
29 </body>
30 </html>
31
32
2 <%@ Import Namespace="System.Threading"%>
3
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
6 <html xmlns="http://www.w3.org/1999/xhtml" >
7 <head runat="server">
8 <title>content</title>
9 <script language="javascript" type="text/javascript" src="http://www.cnblogs.com/Scripts/jquery-1.3.2.js"></script>
10 </head>
11 <body style="background-color:#AAAAAA;">
12 <script language="javascript" type="text/javascript">
13 $(document).ready(function() {
14 setInterval(invoke, 3000);
15 });
16 function invoke() {
17 var xhr = $.ajax({
18 type: "POST",
19 url: "/Home/keepinvoke",
20 data: "",
21 success: function() {
22 var jsonstr = xhr.responseText;
23 $(jsonstr).appendTo("body");
24 }
25 });
26 }
27 </script>
28 <div></div>
29 </body>
30 </html>
31
32