jQuery技术:允许使用AjAx和post方法将数据发送到servlet

function validate (user_value){ var name = user_value; $.ajax({ url:"ggs.erm.servlet.setup5.AjaxS", data:{ namee :name}, success:function(){ alert("worked"); } }); } 

这是我的代码。 有什么问题吗? 任何类型的语法或语义错误。
问题:无法在URL中向servlet发送参数。?????

    如果您希望servlet的doPost方法处理请求,则应添加值为post属性type

     function validate (user_value){ var name = user_value; $.ajax({ url:"ggs.erm.servlet.setup5.AjaxS", data:{ namee :name}, type: 'post', success:function(){ alert("worked"); } }); } 

    这样您的Ajax请求将发布而不是get(默认值)。

    看来你的函数在doc ready handler中检查出来,看看是否有帮助:

      function validate (user_value){ var name = user_value; $.ajax({ url:"ggs.erm.servlet.setup5.AjaxS", type:'POST', //<-----------------added this data:{ namee :name}, success:function(data){ if(data){ alert("worked"); } }, error:function(){ alert('not worked.'); } }); } $(document).ready(function(){ // your other code stuff for calling the function }); 

      以上就是jQuery教程分享允许使用AjAx和post方法将数据发送到servlet相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。

      本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

      ctvol管理联系方式QQ:251552304

      本文章地址:https://www.ctvol.com/jquerytutorial/548116.html

      (0)
      上一篇 2021年1月13日
      下一篇 2021年1月13日

      精彩推荐