Ajax hardcoded value for ajax (newbie)

Can someone tell me how I can make a hardcoded value for the OnSuccess parameter. This code was not mine. I think it was ajax, but I'm still confused what it is.

Just focus on the "data" parameter of the Success parameter

function onSuccess(data) {
    if (data.result) {
        $.App_setLogin(data.data.key1, data.data.key2);
        window.location.href = data.data.url;
    }
}

I want to make a valid hardcoded parameter for onSuccess; sort of

data.data.key1 = "fname";
data.data.key2 = "lname";
data.data.url = "url";
+4
source share
1 answer

Your own example will work fine if it is added inside a function onSuccess. To have the seemingly correct parameter to call onSuccess, you need the following fairly simple object

var param = {
    result: true,
    data: {
        key1: 'key 1',
        key2: 'key 2',
        url: 'url'
    }
};
//onSuccess(param);

, .

+1

Source: https://habr.com/ru/post/1620069/


All Articles