$. post () - Doubt

Asked

Viewed 105 times

0

I got a problem:

I’ve already been able to read and follow the facebook documentation, use their methods and get some hints that they provide. Now that I have achieved this, I need to send for $.post() one of these links (userid).

I’m not getting into the jQuery documentation to understand the use of this method. Someone could help me, I already have two days in this problem and I know it is short time, but as I said, I am not skilled in javascript or in these client side languages.

This is an excerpt from the method where I put it to display inside a div the result of the uid variable that receives userid from the face itself:

FB.getLoginStatus(function(response){

        if (response.status === 'connected'){
            $('#logar').hide();
            $('#status').append('<a href="javascript:void(0);" onclick="logout()" id="logout"></a>');

            var uid = response.authResponse.userID;
            $('#status').html('Seu userID é '+uid+'');              
        } 

    });  

This is what I’m doing to send by $.post(), saying that the content of the div is the info I’m passing and sending after an event click:

(function facebook(){ 
      $("button").click(function(){
        $.post("url-da-minha-escolha", $("#status"), function(data){
            alert(data);
        } )
    }); 
}); 

Anyway, I’ve tried other alternatives too .... this in the case was my last attempt. Anyone who can help me or give a hint or provide a more explanatory material already thank you.

  • Enter more information about the error. Does it give an error? If yes, put the error you are giving. Your "date" variable comes with some value?

  • @Andréluismarmo, no error ... the way it is it returns all the html of the page within the date, when for example I try something like date.name if I have passed the variables by parameter within the post function, it returns Undefined. All the available examples are so simple, even I tried to send the variables inside the function to test. post ex: {name: "name", ... } and even then the return of the date and continues to come all the content of html ... ex: <html><body> etc ... within the variable.

  • If the return is html, it is because this url being given the post does not return a json for example that you can convert and thus get a "data.name". You have to know what the behavior of the url you are performing the post. You may have to give the post but the navigation will continue in the destination url and if so you will not be able to use the jquery post.

  • I managed to solve my problem, thank you very much to those who tried to help! The solution I found was to use the post method itself but on the request page I used resources from the coldfusion form and am printing on the screen the value of the desired variable. Ahh also turned the variable into global, so within the post method itself I read the value that comes from facebook ;)

  • Here we do not write "solved" in the question. If you have an answer that really helped you, mark it as accepted. If you arrived alone

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.