繁体   English   中英

无法输出Javascript信息

[英]Having trouble printing out Javascript info

下面是我拥有的代码,而不是自动将信息添加到ID为#userid的div中,我实际上需要打印出用户ID(当前,它只是将其添加到div中,但我需要能够只需在我想要的位置打印它,而不是将其自动添加到div换行)。

我的最终目标是获取USER ID,然后将其放入WordPress查询中(该用户ID当前用作帖子标记,我需要从该特定用户中提取所有帖子,因此我想按标签查询帖子)

<script src="http://connect.soundcloud.com/sdk.js"></script>  
<script>
  SC.initialize({
    client_id: "a808af7fabb53ad7971c6c9675f392b3",
    redirect_uri: "http://madebyguerrilla.com/clients/2012/theappreciationengine/wordpress/wp-content/themes/TheAppreciationEngine_WP/callback.html"
  });

  $("#connect").live("click", function(){
    SC.connect(function(){
      SC.get("/me", function(me){
        $("#username").text(me.username);
        $("#userid").text(me.id);
      });
    });
  });

  $("#update").live("click", function(){
    SC.put("/me", {user: {description: $("#description").val()}}, function(response, error){
      if(error){
        alert("Some error occured: " + error.message);
      }else{
        alert("Profile description updated!");
      }
    });
  });
</script>

任何帮助,将不胜感激。

您是否有机会接触JS? 开玩笑。

SC.get()调用中,您可以以me.id的身份访问ID:

var userId;

SC.get("/me", function(me){
    $("#username").text(me.username);
    $("#userid").text(me.id); // <-- This is the user id, you can store it in a variable
    userId = me.id; //           <-- like this
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM