Open child windows based on the parent window, the effect is super dazzle, with jquery ajax dynamic No refresh submit ...
The following is the first analysis of code: parent form page Code
-->
<
Div
>
<
a
href
= "Web effects: void (0);"
URL
= ' openerweb.asp tutorial x '
ID
= "Aparent"
>
Edit
</
a
>
<
Div
ID
= "Blockoptip"
style
= "Display:none;"
class
= "Tipbox"
><
img
src
= "Http://images.cnblogs.com/busy.gif"
alt
= "Wait"
/>
<
span
ID
= "Blockoptipaction"
>
saving, please wait a moment ...
</
span
></
Div
>
<
Div
ID
= "Wrap"
>
<
Div
><
img
src
= "/styles/1/busy.gif"
ID
= "Wrapimg"
/><
span
ID
= "Wraptitle"
></
span
></
Div
>
<
Div
ID
= "Wrapbtn"
><
input
class
= "OK"
type
= "button"
/><
input
class
= "Cancel"
type
= "button"
/></
Div
>
<
iframe
ID
= "Blockframe"
style
= "Display:none"
name
= "Blockframe"
width
= "100%"
Height
= "100%"
frameborder
= "0"
scrolling
= "Auto"
></
iframe
>
</
Div
>
</
Div
>
Child Form code:
-->
<
Div
class
= "Managerform"
>
<
form
ID
= "Form1"
runat
= "Server"
>
Child windows ... dddd .
</
form
>
<
Div
ID
= "Blockoptip"
style
= "Display:none;"
class
= "Tipbox"
><
img
src
= "/images/busy.gif"
alt
= "Wait"
/>
<
span
ID
= "Blockoptipaction"
>
saving, please wait a moment ...
</
span
></
Div
>
<
Div
ID
= "Wrap"
>
<
Div
><
img
src
= "/styles/1/busy.gif"
ID
= "Wrapimg"
/><
span
ID
= "Wraptitle"
></
span
></
Div
>
<
Div
ID
= "Wrapbtn"
><
input
class
= "OK"
type
= "button"
/><
input
class
= "Cancel"
type
= "button"
/></
Div
>
<
iframe
ID
= "Blockframe"
style
= "Display:none"
name
= "Blockframe"
width
= "100%"
Height
= "100%"
frameborder
= "0"
scrolling
= "Auto"
></
iframe
>
</
Div
>
</
Div
>
The JS code for the parent window:
<script type= "Text/javascript" >
function Savedetail () {
Alert ("OK");
$.ajaxcommon ("Saving, please be patient ...", "Openerweb.aspx?act=save", NULL, function (p) {
if (P.SUCC) {Parent.unblock ();}
});
return false;
}
</script>
Both the subpage and the parent page refer to Jextending.js, which has two main aspects, respectively, as follows:
function Showedit (src, title, width, height, savecallback,bottom,showintop) {
Submitfunc=null;
Loadfunc = null;
Whether Var b=bottom==undefined?true:bottom;//requires the Save Close button at the bottom
if (PARENT.P = = True && showintop!=false&&showintop==undefined) {
If the parent window is present, the pop-up box for the parent window is started
Parent.showedit (src, title, width, height, savecallback, b,true);
Return
}
Submitfunc = (Savecallback = = Undefined | | | savecallback = NULL)? (function () {}): Savecallback;
var isobject= (typeof (src) = = "Object");
var obj=src;
if (!isobject) {
var href = src;
if (Href.indexof ('? ') > 0) {
href + + "&mm=" + math.random ();
}
else {
href = "mm=" + math.random ();
}
obj=$ ("#blockframe"). attr ("src", href);
}
$.load ("Loading ...");
Loadfunc=function () {
UB (TRUE);
$.blockui ({message:obj, theme:true, Title:title,fadeout:false,needbottom:b,
Themedcss Tutorial: {width:width, height:height},
Onblock:function () {
if (typeof (submitfunc) = = "function") {
$ ("#blockdiv"). Find (". Bottom input[name= ' save ']"). Bind ("click", Function () {Submitfunc ();}); Execute Save button
}
}
});
};
SetTimeout (loadfunc,2000);
}。 This is a function that opens the subpage, which includes the deferred load effect setting and the settings for opening the window. The second function is the Ajaxcommon commit processing function.
$.ajaxcommon = function (title, URL, data, callback, Isonlycallback) {
$.load (title); Set Load Status
$.ajax ({
Url:url + (Url.indexof ("?") = = 1? "?": "&") + "s=" + math.random (),
Type: ' Post ',
DataType: ' JSON ',
Data:data,
Error:function (a) {
$.error (a);
},
Success:function (JSON) {
if (json.succ = = 1 | | json.succ) {
SetTimeout ("$.correct (' + json.message +") ", 500);
Timeoutfunc = settimeout ("UB ()", 1500);
if (typeof (callback) = = "function") {
Window.settimeout (Callback,1700,json);
}
}
else {
var info = Json.info | | Json.message;
if (isonlycallback!=undefined&&isonlycallback==true) {callback (JSON);
$.error (info);
Callback (JSON);
}
Return
}
});
This is a function of the Ajax commit process, including the loading state, the return of the processing result, and the closing of the child window.