Open child windows in the same page parent window, dynamic no refresh commit (1/2)

Source: Internet
Author: User
Tags commit
Open child windows in the same page parent window, dynamic No refresh submission, Super Dazzle based on jquery Ajax submission, compatible with ie7+, Firefox.

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.

Home 1 2 last page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.