The difference between ajax requests and page data (which exists during page loading)

Source: Internet
Author: User

Click the pop-up layer to hide other pop-up layers. (1. Hide all layers. 2. Determine whether the pop-up layer is displayed. If it is displayed, it is hidden. If it is hidden, it is displayed)
1. For ajax request data, use
$ ("# SimpleTip"). click (function (e ){
HideAllProp ();
If ($ ('# simple_cont'). is (": visible ")){
$ ("# Simple_cont"). hide ();
} Else {
$ ("# Simple_cont" ).css ({top: $ (this ). offset (). top + $ (this ). height (), left: $ (this ). offset (). left-18 }). show ();
$ ("# Simple_cont ul" ).html ("");
Var data = {};
Var dictionaryTable_Name = "complaint type ";
Var dictionaryClass_Name = "Complaint Service ";
Data = {dictionaryTable_Name: dictionaryTable_Name, dictionaryClass_Name: dictionaryClass_Name };
$. Ajax ({
Type: "POST ",
Url: getDictionaryAction,
DataType: "text ",
Data: data,
Success: function (data ){
Var jsonArr = data. split ("| ");
Var dataArr = eval ("(" + jsonArr [0] + ")");
Var elem;
For (var I = 0, j = dataArr. length; I <j; I ++ ){
$ ('<Li complaintsType =' + dataArr [I]. dictionaryItem_ID + '>' + dataArr [I]. itemName + '</li> '). appendTo ("# simple_cont ul "). click (function (){
Var complaintsType = $ (this). attr ("complaintsType ");
HideAllProp ();
$. Ajax ({
Url: complaintRegist,
Type: "post ",
DataType: "text ",
Data: {complaintRegisterSource: 1, complaintsType: complaintsType },
Success: function (data ){
$ (". IframeDiv"). show ();
ShowModal ();
$ ("# Success_pro" ).css ({left: $ ("div. rightCon "). offset (). left + 200, top: $ ("div. rightCon "). offset (). top + 100 }). show ();
Type = "simple ";
},
Error: function (data ){
$ (". IframeDiv"). show ();
ShowModal ();
$ ("# Failure_acc" 2.16.css ({left: $ ("div. rightCon "). offset (). left + 200, top: $ ("div. rightCon "). offset (). top + 100 }). show ();
}
});
});
}
},
Error: function (){
// HideFunPanel1 (0); hideFunPanel2 (0 );
$. Alert ("failed to get data! ");
}
});
// $ ("# Simple_cont" ).css ({left: $ (this ). offset (). left-$ ("# simple_cont "). width () + $ (this ). width (), top: $ (this ). offset (). top + $ (this ). height ()}). show ();
}
E. stopPropagation (); www.2cto.com
});
The click event cannot be directly used $ ("ul li"). click (function) {}); because ul li does not exist during page loading but is obtained through ajax requests.

From the web Front-end wyy Column

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.