When I try to use the token data it acts like it is out of scope or it leaked. I have tested this in firefox and cannot figure out what is happening. If you could help me understand why it fails to return the token please feel free to reply.

the code that retreives the token:

$(function() {
    var request = $.ajax({
        type: "GET",
        cache: false,
        data: {v: 1, r: 'requestToken', apikey: 'root', secret: 'root'},
        url: "/vdesktop/deskapi/",
        dataType: "json",

    });
    request.done(function(data) {
        if (data.statusCode == 1) {
                $token = data.response;
                $(document.body).data("token", data.response);
            } else{
                alert("Error: ("+data.statusCode+") "+data.response);
            }
    });
    request.fail(function(jqXHR, textStatus) {
        alert("Error: "+textStatus);
    });
    alert($(document.body).data("token"));
});

An example resultset from the server:
{"statusCode": 1, "response": "1fa8997a0cb5062144b25c1ff917a5f293bee88b62cd4f99aca26fda12515372" }

Recommended Answers

All 7 Replies

Member Avatar for LastMitch

When I try to use the token data it acts like it is out of scope or it leaked.

What do you mean by leaked? What kind of API are you using?

The token is empty/not returning a value once it gets to the alert on line 21 but it has a value in the ajax call. The API is a custom API I am developing for a new service I am putting together. The API is based off of OAuth 2. if you are refering to the js library I am using it is jquery.

Member Avatar for LastMitch

The API is a custom API I am developing for a new service I am putting together.

You are pretty much on your own with this.

I thought it might be related to Facebook, Twitter, or any other OAuth API or Web applciation. If you are creating something on your own it's hard to anyone to help you because most likely has nothing to do with what I mention above (Facebook, Twitter, or any other OAuth API).

Ah ok. I did give an example json result in my first post so you guys have something to work with. I was hoping if someone can see a glaring mistake that has resulted in the token not being passed beyond the ajax call. Anyways thanks for your time LastMitch.

I don't understand the meaning of the word "token" in your usage. So I'm not sure I understand the problem you are facing. And you are using that "$" thing, which points that - the best pro:help you could get with this, lies at its lib., official web address.

The token stands for security token used in OAuth which is actually data.response in the json result.

LOL! I didn't know that jquery had a forum. I'll try there.

this would mean that the thread is solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.