locked
How wait response server when calling page .ashx RRS feed

  • Question

  • Hi

    I have a project in LightSwitch Html.
    I have a list of Customer and I created a button which allow by download a file .csv for all list Customers.
    So, when I click a button I wait what the application call a file .ashx for download the file.
    But I would create something for understand that is loading and know when it finished.
    This, is possible?
    Thanks, best regards

    Tuesday, August 13, 2013 2:56 PM

Answers

  • See:

    Using Promises In Visual Studio LightSwitch

    myapp.PromiseOrders.created = function (entity) {
        // Using a Promise object we can call the CallGetUserName function
        msls.promiseOperation(CallGetUserName).then(function PromiseSuccess(PromiseResult) {
            // Set the result of the CallGetUserName function to the 
            // UserName of the entity
            entity.UserName = PromiseResult;
        });
    };
    
    
    // This function will be wrapped in a Promise object
    function CallGetUserName(operation) {
        $.ajax({
            type: 'post',
            data: {},
            url: '../web/GetUserName.ashx',
            success: operation.code(function AjaxSuccess(AjaxResult) {
                operation.complete(AjaxResult);
            })
        });
    }


    Unleash the Power - Get the LightSwitch HTML Client book

    http://LightSwitchHelpWebsite.com


    • Edited by ADefwebserver Tuesday, August 13, 2013 3:10 PM fix code sample
    • Marked as answer by Arenaut Friday, August 16, 2013 7:13 AM
    Tuesday, August 13, 2013 3:09 PM