DIV achieve expansion nested pages read AJAX
Use <div id = "DIV logo" type = "digital" ajaxurl = "address"> </ div>
XML format roughly as follows:
<? Xml version = "1.0" encoding = "utf-8?">
<root>
<styletype Id="0" imgsrc="images/loading/loading.gif"> Loading …….</ styletype>
<styletype Id="1"> <! [CDATA [Loading ….< br> <img src='images/loading/loadingbar2.gif' /> ]]></ styletype>
</ Root>
That is the definition of XML id = pattern corresponding to the number of nested read AJAX.
For example a.htm:
<div Id="da" type="0" ajaxurl="b.htm"> </ div>
B.htm:
<div Id="db" type="1" ajaxurl="c.htm"> </ div>
<div Id="dc" type="1" ajaxurl="d.htm"> </ div>
C.htm:
Rtrtrtrtrtrtrt
D.htm:
Aaaaaaaaaaaa
A.htm open in the DIV da b.htm read, and then in having da db, dc two, and then in the process db, respectively dc read c.htm and d.htm
Until the end of nesting
Code as follows:

= (Var ajax …
/ / Is not the first time
FirstTime: true,
/ / Synchronous detection array Queue
Arr: A new $ (),
That: false, 
Init: function () (…
/ / First, the Show browser can run this script (Some browsers can not be used getElementsByTagName) 
If (! Document.getElementsByTagName) (…
Return;
) 
This.that = this;
This.run (); 
) 
/**//**
* Traversal of all div document, if ajaxurl attribute, the application of this script
*
** / 
Run: function () (…
/ / Get all DIV layer
Var divs = document.getElementsByTagName ( "div");
/ / Get-SPAN all
Var spans = document.getElementsByTagName ( "span");
/ / Divs into the array and add all DIV layer
A new $ divs = (divs);
/ / Divs to accede to all of SPAN 
For (var u = 0; u <spans.length; u + +) (…
Divs.push (spans [u]);
)
/ / Load the first time: join the queue of all arr 
If (this.arr.length & this.firstTime == 0) (…
This.firstTime = false; 
For (var i = 0; i <divs.length; i + +) (…
This.arr = this.arr.concat (divs [i]. Id);
)
)
/ / Not the first time: the implementation of the existing layer and the End of the queue so bad set, that the new layer of untreated 
Else (… 
For (var j = 0; j <divs.length; j + +) (… 
For (var i = 0; i <this.arr.length; i + +) (… 
If (divs [j]. Id == this.arr [i]) (…
Divs.splice (j, 1);
)
)
)
)
/ / Layer of untreated cycle, and then the implementation of AJAX operation 
For (var i = 0; i <divs.length; i + +) (…
Var thisDiv = divs [i]; 

If (thisDiv.getAttribute ( 'ajaxurl')! = Null) (…
This.makeAjax (thisDiv);
/ / Queue to join after the completion of treatment
This.arr = this.arr.concat (thisDiv.id);
)
) 
)
/ / Application prior to the implementation of AJAX style 
MakeAjax: function (theDiv) (…
Var url = theDiv.getAttribute ( 'ajaxurl');
Var typeval = theDiv.getAttribute ( 'type'); 
If (json.result.length == null)
TheDiv.innerHTML = "<div align=center style='position:relative;'> <img src='" + + "'/> json.result.styletype.imgsrc" json.result.styletype.content + + "< / div> ";
Else
TheDiv.innerHTML = "<div align=center style='position:relative;'>" + json.result [parseInt (typeval)]. Styletype.content + "</ div>";
/ / Implementation of AJAX 
SetTimeout ( "doAjax ( '" + + "','" theDiv.id + url +"')", 1000);
)
/ / Will be "read" the effect of the market available to other procedures used 
RunAjax: function (theDiv) (…
/ / Var url = theDiv.getAttribute ( 'ajaxurl');
Var typeval = theDiv.getAttribute ( 'type');
If (typeval == null)
Typeval = "0";
If (json.result.length == null)
TheDiv.innerHTML = "<div align=center style='position:relative;top:50%;height:100%'> <img src='" + + "'/> json.result.styletype.imgsrc" + json . result.styletype.content + "</ div>";
Else
TheDiv.innerHTML = "<div align=center style='position:relative;top:50%;height:100%'>" + json.result [parseInt (typeval)]. Styletype.content + "</ div>" ;
) 

)
/ / Initialization 
Function ajaxInit () (…
/ / Read through URL access patterns to JSON 
New Ajax.Request ( 'Controller / GetJSon.ashx? Name = ajaxdiv',…{ onComplete: continuerun)); 
)
/ / Applications JSON format, and then continue to deal with Cascade 
Function continuerun (e) (…
Eval (e.responseText);
Ajax.init ();
)
/ / End AJAX after the callback 
Function doAfter (e) (…
Ajax.run ();
) 
/ / Specific AJAX operation 
Function doAjax (id, url, pars) (… 
New Ajax.Updater (id, 'Controller / GetHtmlPage.ashx? Page =' + url ,…{ parameters: pars, evalScripts: true, onComplete: doAfter));
) 

/ / Observe patterns in the window onload function to join ajax Cascade
Event.observe (window, 'load', ajaxInit, false);
Method of Use:
Prototype.js rely on the use of the code to be downloaded prototype1.4 above
One / / URL read through the form to obtain JSON
New Ajax.Request ( 'Controller / GetJSon.ashx? Name = ajaxdiv',…{ onComplete: continuerun));
GetJSon.ashx says, reading XML, and put it into the form of JSON:, XML format defined as follows:
<? Xml version = "1.0" encoding = "utf-8?">
<root>
<styletype Id="0" imgsrc="images/loading/loading.gif"> Loading …….</ styletype>
<styletype Id="1"> <! [CDATA [Loading ….< br> <img src='images/loading/loadingbar2.gif' /> ]]></ styletype>
</ Root>
The XML-AJAX pages before reading the definition of the style of display, such as id = 0:00, compared with picture + Loading ……;
Id = 1:00 to Read in …..+< br> + long picture
JSON on XML conversion, please refer to. "The use of Ebay NET XSLT template conversion of XML to JSON"
/ / Specific AJAX operation
Controller / GetHtmlPage.ashx? Page = '+ url simple Acting pages, it provides a pretreatment for ajax, including character sets, such as cache:
Public void ProcessRequest (HttpContext context) 
(…
Lock (this) 
(…
/ / The system relative path
ConfigurationSettings.AppSettings string path = [ "serverrelpath"];
/ / Set up the first information
Context.Response.ContentEncoding = System.Text.Encoding.GetEncoding ( "GB2312");
Context.Response.CacheControl = "no-cache";
/ / Get fixed parameters
Context.Request.Params string page = [ "page"];
/ / Get other parameters
String [] = context.Request.QueryString.AllKeys querys;
String querystring = null;
/ / Assembly of other parameters
If (querys.Length! = 1) 
(…
Foreach (string query in querys) 
(…
If (! Query.Equals (the "page"))
Querystring + = "&" query + + "=" + context.Request.Params [query];
)
/ / Senate Jump
Context.Response.Redirect (path + + querystring page);
)
/ / No Senate Jump
Context.Response.Redirect (path + page);
)
) 
Public bool IsReusable 
(…
Get 
(…
/ / TODO: Add GetHtmlPage.IsReusable getter achieve
Return true;
)
) 
# Endregion
)
Tags: CSS DIV, div class, div css, div css Guide, div css layout, div location
Releated Posts
Categories
- CSS Properties (491)
- CSS Tutorial (1154)
- CSS Tutorial By Examples (1201)
- Css+Div Web Design (3274)
- Xhtml and Web Design (1797)
Archives
Pages






Leave a Reply