Monday, December 10, 2012

Jquery For Each Set Time Out and Ajax Tabes


<script type="text/javascript">
     $(document).ready(function () {
         $("#TabbedPanels1").tabs();
         $.ajax({
             type: "POST",
             url: "Default.aspx/lawersDetailsList",
             data: "{}",
             contentType: "application/json; charset=utf-8",
             dataType: "json",
             success: function (data) {
                 var arrayList = data.d;
                 $.each(arrayList, function (i, val) {
                     setTimeout(function () {
                         $('#slide-1').fadeOut("slow", function () {
                             $(this).html("<h1>" + val.memberName + "</h1>" + "<p>" + val.offAddress + "</p>" + "<a href='LawyerProfile.aspx?id=" + val.memID + "'><img src='MemPhoto/" + val.imageID + "' /></a><br />").fadeIn("slow");
                         });
                     }, i * 5000);
                 });
             }
         });
         var arrayCount = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'];
         $.each(arrayCount, function (j, values) {
             setTimeout(function () {
                 $.ajax({
                     type: "POST",
                     url: "Default.aspx/memberProfilesList",
                     data: "{}",
                     contentType: "application/json; charset=utf-8",
                     dataType: "json",
                     success: function (data) {
                         var arrayList = data.d;
                         $("#membersProfile").fadeOut("slow");
                         $('#membersProfile').html("");
                         $.each(arrayList, function (i, val) {
                             $('#membersProfile').append("<a href='LawyerProfile.aspx?id=" + val.memID + "'><img src='MemPhoto/" + val.imageID + "' width='50px' /></a>");
                         });
                         $("#membersProfile").fadeIn("10000");
                     }
                 });
             }, j * 30000);
         });

         $('#TabbedPanels1').bind('tabsselect', function (event, ui) {
             var callMethod;
             var tabSelected = "#TabbedPanels1" + ui.index + "Selected";
             if ($(tabSelected).text() == "") {
                 switch (ui.index) {
                     case 1:
                         callMethod = "Default.aspx/NewsUpdatesCollections";
                         break;
                     case 2:
                         callMethod = "Default.aspx/DesignatedSeniorsList";
                         break;
                     case 3:
                         callMethod = "Default.aspx/MostViewedprofilesList";
                         break;
                     case 4:
                         callMethod = "Default.aspx/LastViewedprofilesList";
                         break;
                     case 5:
                         callMethod = "Default.aspx/RecentlyUpdatedMembersList";
                         break;

                 }

                 $.ajax({
                     type: "POST",
                     url: callMethod,
                     data: "{}",
                     contentType: "application/json; charset=utf-8",
                     dataType: "json",
                     async: true,
                     success: function (data) {
                         alert(data.d);

                         switch (ui.index) {
                             case 1:
                                 alert(data.d);
                                 break;
                             case 2, 3, 4, 5:
                                 alert(data.d);
                                 break;

                         }


                     }
                 });
             }
         });



     });
 </script>

No comments:

Post a Comment