Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sendRequest(url, type, onSuccess, onError)
- {
- var httpURL = "http://" + cloudURL + ":" + cloudPRT + "/service" + url;
- console.log("Doing " + type + " request on URL " + httpURL);
- var response = $.ajax({
- url: httpURL,
- async: true,
- type: type,
- cache: false
- });
- response.success(onSuccess);
- response.fail(function (a, b, c)
- {
- onError(b, c);
- });
- }
- /****************
- getUserStatVal - parameter - name of the stat (string)
- Currently, 'val' returns undefined even when the stat
- returns properly within the function?
- ****************/
- this.getUserStatVal = function(statName, val)
- {
- var p = {};
- // DO NOT CHANGE false
- sendRequest("/stats/user?getstat=" + statName + "&gameid=" + gameId + "&session=" + sessionId +
- "&all=false", "GET",
- function (result)
- {
- if (result.ResponseType == 0)
- {
- p = JSON.parse(result.AdditionalData);
- console.log(p);
- console.log("session..." + sessionId);
- console.log("name... " + p.stat_name);
- console.log("value... " + p.stat_value);
- val = p.stat_value;
- }
- else
- {
- p = JSON.parse(result.AdditionalData);
- console.log("Err");
- console.log(p)
- }
- },
- function (status, why)
- {
- alert("Error in getUserStatVal function: [status=" + status + "] [reason=" + why + "]");
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment