Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Wednesday, November 13, 2013

Comparing Two Dates formatted (mm/dd/yyyy) using jQuery

Just convert to a Date object and compare your date value to Date.now - for example:

var endDate = Date.parse('4/25/2015'); 
var currentDate = Date.now();
if (endDate >= currentDate) {
                return true;

            }        

Thursday, October 24, 2013

Calling a function inside a function asynchronously using JQuery

var Test;
$(function () {

    var ServicePath = rootPath + "Services/TestService.asmx/";

    var ajxcalls = function (methodname, param, success, error) {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            cache: false,
            async: false,
            url: ServicePath + methodname,
            data: param,
            dataType: 'json',
            success: success,
            error: error
        });
    };

    Test = {
        Init: function () {
            Test.TestCheck();
        },
        TestCheck: function () {
            var isActive = false;
            var par = JSON2.stringify({ ParameterValue: value });
            ajxcall("TestIsActive", par, function (data) { isActive = data.d; }, function () { Alert('Error'); });
            Alert(isActive);
        }
    };
    Test.Init();
});