Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
JavaScript
function runFunctionIfAvailable(callback, params) {
        try {
            if (typeof callback !== 'undefined') {
                if ($.isFunction(callback)) {
                    if (params !== null) {
                        return callback(params);
                    } else {
                        return callback();
                    }
                } else if (typeof callback === 'string') {
                    var f = new Function(callback);
                    if (params !== null) {
                        return f.call(params, params);
                    } else {
                        return f();
                    }
                }
            }
        } catch (e) {
            return false;
        }
    };

    login.SubmitJsonpForm = function (form, onSuccessCallback, onBeginCallback, onErrorCallback, onCompleteCallback) {
        var result = runFunctionIfAvailable(onBeginCallback);
        if (result !== false) {
            var url = form.attr("action");

            if (url.indexOf('?') === -1) {
                url = url + "?jsoncallback=?";
            } else {
                url = url + "&jsoncallback=?";
            }
            
            var formItems = form.serializeArray();
            var added = [];

            $.each(formItems, function () {
                if ($.inArray(this.name, added) === -1) {
                    added.push(this.name);
                    $.cookie("__jsonpform_" + this.name, this.value, { secure: true, path: '/' });
                }
            });

            try {
              
                $.getJSON(
                    url,
                    function (data) {
                        runFunctionIfAvailable(onSuccessCallback, data);
                    })
                    .error(function () {
                        runFunctionIfAvailable(onErrorCallback, null);
                    })
                    .complete(function () {
                        /* This is extra protection. Response automatically removes jsonp request cookies. */
                        clearCookies(added);

                        runFunctionIfAvailable(onCompleteCallback, null);
                    });
            } catch (e) {
                if (added) {
                    /* This is extra protection. Response automatically removes jsonp request cookies. */
                    clearCookies(added);
                    runFunctionIfAvailable(onErrorCallback, null);
                }
            }
        } else {
            runFunctionIfAvailable(onCompleteCallback, null);
        }
    };



I am Getting the Following URL:

http://localhost/home/login?jsoncallback=?


Its working well in after hosting in server but in local system the action was not firing . the functionality is not working

please tell me the problem and how to run it on local.
Posted
Updated 13-May-15 4:06am
v2
Comments
Afzaal Ahmad Zeeshan 13-May-15 10:07am    
What is the error that you stumble upon? Can you share the error please. So that we can further look into the trouble.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900