JavaScript POST方法问题 [英] JavaScript POST method problem

查看:65
本文介绍了JavaScript POST方法问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在asp.net web应用程序中我有js脚本在Sendy上发布数据。我的代码:

Hi,
in asp.net web application i have js script to post data on Sendy. My code:

<script type="text/javascript">
    function sendy(nameS, emailS, listID, listUrl) {
        $.ajax({
            type: "POST",
            url: listUrl,
            data: {
                email: emailS,
                list: listID,
                name: nameS
            }
        });
    }
</script>





此代码不起作用。如果我在和添加警报,它就会开始工作。带警报的代码:



This code dont work. If I add alert at the and, it starts to work. Code with alert:

<script type="text/javascript">
    function sendy(nameS, emailS, listID, listUrl) {
        $.ajax({
            type: "POST",
            url: listUrl,
            data: {
                email: emailS,
                list: listID,
                name: nameS
            }
        });
        alert("1");
    }
</script>





我能做些什么来使它工作而我不需要警报?我可以在用户看到窗口之前自动关闭警报弹出窗口吗?



谢谢



What can I do to make it work and I dont need alert? Can I close the alert popup automatically,
before user see the window?

Thanks

推荐答案

.ajax({
type: POST
url:listUrl,
data:{
email:emailS,
list:listID,
name:nameS
}
});
}
< / script>
.ajax({ type: "POST", url: listUrl, data: { email: emailS, list: listID, name: nameS } }); } </script>





此代码不起作用。如果我在和添加警报,它就会开始工作。带警报的代码:



This code dont work. If I add alert at the and, it starts to work. Code with alert:

<script type="text/javascript">
    function sendy(nameS, emailS, listID, listUrl) {


.ajax({
type : POST
url:listUrl,
data:{
email:emailS,
list:listID,
name:nameS
}
});
alert( 1);
}
< / script>
.ajax({ type: "POST", url: listUrl, data: { email: emailS, list: listID, name: nameS } }); alert("1"); } </script>





我能做些什么来使它工作而我不需要警报?我可以在用户看到窗口之前自动关闭警报弹出窗口吗?



谢谢



What can I do to make it work and I dont need alert? Can I close the alert popup automatically,
before user see the window?

Thanks


无需提醒。由于它是一个Ajax调用,你需要依赖回调(完成,失败和总是),如下面的示例所示:



No need to have an alert. Since it is an Ajax call you need to rely on callbacks (done, fail and always) as shown in below sample:

// Assign handlers immediately after making the request,
// and remember the jqXHR object for this request

var jqxhr =


这篇关于JavaScript POST方法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆