【问题标题】:JQuery postback doesn't workJQuery回发不起作用
【发布时间】:2012-02-28 08:39:44
【问题描述】:

我有这样的功能;

    <script type="text/javascript">            
        function callUrl(url) {       
            $.post(url);
            alert('You'll redirect a telephone');
        }        
    </script>

我只想工作网址。当 url 起作用时,用户拨打电话。我正确地获取了网址。但是 $.post(url);不起作用。你如何解决这个问题?

【问题讨论】:

  • 你期望发生什么?
  • 我想打开那个网址,但用户一定看不到。

标签: javascript asp.net c#-4.0


【解决方案1】:

将成功处理程序传递给 $.post 方法以执行您的回调。

$.post(url, function(data) {
   // Call the phone here
});

【讨论】:

    【解决方案2】:

    你需要使用encodeURIComponent函数对url进行编码

    <script type="text/javascript">            
            function callUrl(url) {       
                $.post(encodeURIComponent(url));
                alert('You\'ll redirect a telephone');
            }        
        </script>
    

    【讨论】:

      【解决方案3】:

      你需要写“成功”

       $.ajax({
        url: "test.html",
        success: function(){
        alert("");
        }
      });
      

      【讨论】:

        最近更新 更多