相关疑难解决方法(0)

jQuery ajax成功回调函数定义

我想使用jQuery ajax从服务器检索数据.

我想将成功回调函数定义放在.ajax()块之外,如下所示.那么我需要声明变量dataFromServer如下所示,以便我能够使用成功回调中返回的数据吗?

我见过大多数人在.ajax()块内定义成功回调.如果我想在外面定义成功回调,那么以下代码是否正确?

var dataFromServer;  //declare the variable first

function getData() {
    $.ajax({
        url : 'example.com',
        type: 'GET',
        success : handleData(dataFromServer)
    })
}

function handleData(data) {
    alert(data);
    //do some stuff
}
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery

85
推荐指数
5
解决办法
33万
查看次数

Sharethis按钮不适用于通过ajax加载的页面

我试图在通过ajax加载的页面上使用sharethis按钮.按钮不显示.请帮忙.

此致,Pankaj

sharethis

15
推荐指数
2
解决办法
1万
查看次数

如何使用带有javascript函数的自定义URL动态创建"共享此按钮"?

我使用http://sharethis.com/按钮为网站上的用户提供了一种分享内容的简单方法.

他们在这里有关于"自定义按钮"的信息:http://help.sharethis.com/customization/custom-buttons

看起来像指定URL,在示例中他们只有像这样的html:

<span class="st_sharethis" st_url="http://mycustomurl.com" st_title="Sharing Rocks!"
displayText="ShareThis"></span>
Run Code Online (Sandbox Code Playgroud)

但我需要能够在不重新加载页面的情况下动态创建按钮.

所以,在一个flash应用程序我正在构建我有一个"分享按钮",触发网页上的javascript功能,使"弹出"div淡入屏幕中心,我想显示共享按钮.根据用户点击的共享按钮,它需要具有动态创建的URL.

重要的是,如果他们关闭对话框,然后再次单击共享按钮,我希望代码将使用新的按钮覆盖旧代码,使用新的url/titles.

所以,我创建了这个我从flash调用的javascript函数,同时从flash传递url.我将脚本和所有内容放在我的"弹出"div中,希望按钮将在该div内部呈现.

function shareChannel(theurl)
{
//I cant seem to find an example of what to put here to load the buttons, and give them a custom URL and title

//finally display the popup after the buttons are made and setup.
displaypopup();
}
Run Code Online (Sandbox Code Playgroud)

有没有人可能发布一个例子,说明如何在不重新加载页面的情况下做到这一点?

编辑:@Cubed

<script type="text/javascript">
function shareChannel(chaan)
          {

          document.getElementById('spID1').setAttribute('st_url', 'http://mycustomurl?chan='+chaan);
          document.getElementById('spID1').setAttribute('st_title', 'Custom Title is ['+chann+'] it works!');

          stButtons.locateElements();

          centerPopupThree();
          loadPopupThree();
          }

</script>
Run Code Online (Sandbox Code Playgroud)

基本上没有任何反应.我讨厌使用javascript,因为我真的不知道如何获取错误消息或调试.当我使用flex时,我有一个很好的调试器/控制台来解决问题.所以,抱歉我无法提供更多信息.当我删除时,我注意到了 …

html javascript social ajax sharethis

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

ajax ×2

javascript ×2

sharethis ×2

html ×1

jquery ×1

social ×1