weixin_33682790 2014-04-15 16:05 采纳率: 0%
浏览 34

Javascript AJAX方法

why does this not work?

    function AjaxCall (FormName, PHPFunction) {
    alert(FormName);
    $.ajax({
        type: "GET",
        url: "webservice.php?method=" + PHPFunction,
        data: $("'" + FormName + "'").serialize(),
        success: function (response) {
            alert(response);
        },
        failure: function (response) {
            alert(response);
        }
    }); 
   }

and this is the call from the form:

<form id="form_login" name="form_login" method="POST" onsubmit="return AjaxCall('form_login','CheckUserLogin')">

Thank you

  • 写回答

2条回答 默认 最新

  • Lotus@ 2014-04-15 16:07
    关注

    FormName will be 'form_login', which you use as a jQuery selector which would match <form_login> elements if you weren't adding quotes to the string, but simply isn't a valid selector as you are.

    Don't mess around with passing identifying strings, just pass the element itself.

    onsubmit="return AjaxCall(this, ...
    

    and

    $(FormName)
    
    评论

报告相同问题?

悬赏问题

  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表