简体   繁体   English

jQuery回发不起作用

[英]JQuery postback doesn't work

I've a function like this; 我有这样的功能;

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

I'm only want to work url. 我只想工作网址。 When the url'll worked, the user call a telephone. 网址生效后,用户拨打电话。 I'm correctly getting url. 我正确获取了网址。 But $.post(url); 但是$ .post(url); doesn't work. 不起作用。 How do you solve this? 您如何解决呢?

Pass a success handler to the $.post method to perform your callbacks. 将成功处理程序传递给$ .post方法以执行回调。

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

you need to encode url use encodeURIComponent function 您需要编码url使用encodeURIComponent函数

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

You need to write "success" 您需要写“成功”

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

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

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