آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

 راهنمایی در خصوص داینامیک کردن یک کد

MasterSPYware  9 سال پیش  9 سال پیش
0 0

سلام.من یک کد اجکس دارم.میخوام داینامیکش کنم

اما نمیدونم چطوری-کسی میتونه کمک کنه؟

+1 0
شما بشیند بنویسد هر جا که به مشکل برخوردید بگید تا مشکل رو حل کنیم (9 سال پیش)
 برای این سوال 2 پاسخ وجود دارد.
پاسخ به سوال 
MasterSPYware  9 سال پیش
0 0

کد من اینه:این کد دانلود شده،برای همین گیج کنندست

کد html صفحه شروع:

 <html>
    <head>
        <title>Lazy Load Demo</title>
        <link rel="stylesheet" href="./styles.css" />
    </head>
    <body>
        <div id="wrapper">
            <h1>Lazy Load Demo</h1>
            <div id="data-container">
                <div class="data-item">
                    Hi! I am the first item.
                </div>
                <div class="data-item">
                    Hi! I am the second item.
                </div>
                <div class="data-item">
                    Hi! I am the third item.
                </div>
                <div class="data-item">
                    Ok, this is getting boring.
                </div>
                <div class="data-item">
                    Let's try something new.
                </div>
                <div class="data-item">
                    How about loading some more items through AJAX?
                </div>
                <div class="data-item">
                    Click the button below to load more items.
                </div>
            </div>
            <div id="button-more" onclick="lazyload.load()">
                Load more items
            </div>
            <div id="loading-div">
                loading more items
            </div>
        </div>
        <script type="text/javascript" src="./jquery.1.10.min.js"></script>
        <script type="text/javascript" src="./lazyload.js"></script>
    </body>
</html>

 

کد صفحه لود 1 و 2 و 3 و ... که تکرار میشه:

 <div class="data-item">
    I just got loaded through AJAX!
</div>
<div class="data-item">
    Isn't that cool?
</div>
<div class="data-item">
    Let's try it again, shall we?
</div>
<div class="data-item">
    Click on the button again and see what happens.
</div>

اینم کد ajax:اسم فایل lazyload.js هستش

 var lazyload = lazyload || {};

(function($, lazyload) {

    "use strict";

    var page = 2,
        buttonId = "#button-more",
        loadingId = "#loading-div",
        container = "#data-container";

    lazyload.load = function() {

        var url = "./" + page + ".html";

        $(buttonId).hide();
        $(loadingId).show();

        $.ajax({
            url: url,
            success: function(response) {
                if (!response || response.trim() == "NONE") {
                    $(buttonId).fadeOut();
                    $(loadingId).text("No more entries to load!");
                    return;
                }
                appendContests(response);
            },
            error: function(response) {
                $(loadingId).text("Sorry, there was some error with the request. Please refresh the page.");
            }
        });
    };

    var appendContests = function(response) {
        var id = $(buttonId);

        $(buttonId).show();
        $(loadingId).hide();

        $(response).appendTo($(container));
        page += 1;
    };

})(jQuery, lazyload);

میخوام بجای اینکه از جایی استاتیک دستور بگیره-داینامیک دستور بگیره

0 0
ممنون (9 سال پیش)
0 0
امین جان اینو هم دریاب (9 سال پیش)
+1 0
الان همین کدرو که اجرا میگیرد تو قسمت network و console مرورگرتون چی بهتون خروجی میده ؟؟ (9 سال پیش)
پاسخ به سوال 
MasterSPYware  9 سال پیش
0 0

بار اول 2.html

بار دوم 3.html

بارسوم4.html

در قسمت network


پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .