Click here to Skip to main content
15,886,199 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: variable undefined Pin
Rahul VB22-Oct-16 8:28
professionalRahul VB22-Oct-16 8:28 
GeneralRe: variable undefined Pin
wfzen25-Oct-16 12:20
wfzen25-Oct-16 12:20 
Questiongenerate html on separate page Pin
dcof17-Oct-16 10:22
dcof17-Oct-16 10:22 
Rant[REPOST] generate html on separate page Pin
Richard Deeming18-Oct-16 2:00
mveRichard Deeming18-Oct-16 2:00 
QuestionSave form data without using Php Pin
LincolnMugasho16-Oct-16 6:21
professionalLincolnMugasho16-Oct-16 6:21 
AnswerRe: Save form data without using Php Pin
F-ES Sitecore16-Oct-16 23:21
professionalF-ES Sitecore16-Oct-16 23:21 
AnswerRe: Save form data without using Php Pin
Nathan Minier17-Oct-16 1:09
professionalNathan Minier17-Oct-16 1:09 
Questioncosmetic fix, get the spinner to show for a second Pin
jkirkerx14-Oct-16 9:43
professionaljkirkerx14-Oct-16 9:43 
I wrote this from scratch, and I'm trying to get the addClass to run the font spinner before the $ajax runs; but the $ajax is so fast, that the spinner never shows.

I tried queue, which works, if I queue after changing the class. But when I try to run it a 2nd time, it runs but sort of does nothing. I destroyed my queue work and reverted back to the sample below.

Tried Delay, but that seems to only work with animation.

Tried setTimeout, but had no luck.

Just nice to have, but can live without it.
function js_add2Cart(_sku) {

    var $itemQty = $("#selectQty"),
        $itemType = $("#Type"),
        $spinner = $("#js-add2Cart > i"),
        $NavCart = $("#navCartCount"),
        _qty = parseInt($itemQty.val()),
        _type = $itemType.val();

    // Delay and queue the spinner for visual success<br />
    if (isNaN(_qty)) { _qty = 1; }
    $.ajax({
        type: "POST",
        cache: false,
        dataType: "json",
        url: '/Ajax/json_add2cart',
        data: { Sku: _sku, Qty: _qty, Type: _type },
        beforeSend: function () {
            $spinner.addClass('fa-cog fa-spin');
            $("#js-add2Cart").html('Add to Cart').removeClass('error').addClass('add2cart');
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $("#js-add2Cart").removeClass('add2cart').addClass('error').html('Error has occured');
        },
        success: function (data) {
            // Update the Cart Qty in Store Layout<br />
            $NavCart.text(data);
        },
        complete: function () {
            $("#js-add2Cart").html('Item added');
            $spinner.removeClass('fa-cog fa-spin');
        }
    });

}

AnswerRe: cosmetic fix, get the spinner to show for a second Pin
Richard Deeming17-Oct-16 2:00
mveRichard Deeming17-Oct-16 2:00 
GeneralRe: cosmetic fix, get the spinner to show for a second Pin
jkirkerx17-Oct-16 6:29
professionaljkirkerx17-Oct-16 6:29 
GeneralRe: cosmetic fix, get the spinner to show for a second Pin
jkirkerx17-Oct-16 6:53
professionaljkirkerx17-Oct-16 6:53 
GeneralRe: cosmetic fix, get the spinner to show for a second Pin
Richard Deeming17-Oct-16 7:38
mveRichard Deeming17-Oct-16 7:38 
GeneralRe: cosmetic fix, get the spinner to show for a second Pin
jkirkerx17-Oct-16 10:15
professionaljkirkerx17-Oct-16 10:15 
QuestionBig Data beginner, where do I start? Pin
roraaa_9-Oct-16 16:58
roraaa_9-Oct-16 16:58 
AnswerRe: Big Data beginner, where do I start? Pin
Richard MacCutchan9-Oct-16 21:52
mveRichard MacCutchan9-Oct-16 21:52 
GeneralRe: Big Data beginner, where do I start? Pin
Mycroft Holmes9-Oct-16 22:33
professionalMycroft Holmes9-Oct-16 22:33 
QuestionDealing with browser caching and updated script files Pin
Matt U.28-Sep-16 9:39
Matt U.28-Sep-16 9:39 
AnswerRe: Dealing with browser caching and updated script files Pin
User 171649228-Sep-16 12:31
professionalUser 171649228-Sep-16 12:31 
GeneralRe: Dealing with browser caching and updated script files Pin
Matt U.28-Sep-16 12:33
Matt U.28-Sep-16 12:33 
QuestionHow to grab the value of id from the GET query with JavaScript or jQuery? Pin
Bokleence24-Sep-16 23:17
Bokleence24-Sep-16 23:17 
AnswerRe: How to grab the value of id from the GET query with JavaScript or jQuery? Pin
Afzaal Ahmad Zeeshan24-Sep-16 23:58
professionalAfzaal Ahmad Zeeshan24-Sep-16 23:58 
GeneralRe: How to grab the value of id from the GET query with JavaScript or jQuery? Pin
Bokleence25-Sep-16 0:26
Bokleence25-Sep-16 0:26 
GeneralRe: How to grab the value of id from the GET query with JavaScript or jQuery? Pin
Afzaal Ahmad Zeeshan25-Sep-16 0:37
professionalAfzaal Ahmad Zeeshan25-Sep-16 0:37 
GeneralRe: How to grab the value of id from the GET query with JavaScript or jQuery? Pin
Bokleence25-Sep-16 0:55
Bokleence25-Sep-16 0:55 
QuestionJasmine testing Angular issues Pin
cjb11023-Sep-16 0:04
cjb11023-Sep-16 0:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.