weixin_33699914 2016-12-13 12:58 采纳率: 0%
浏览 17

绑定输入类型提交

I have Registration.html fail, which contains registration form. The other failure is in KinveyRequester.js

function registerUser(e) {
    e.preventDefault();

    let userData = {
      username: $("#registerUsername").val(),
      password: $("#registerPassword").val()
    };
    $.ajax({
      method: "POST",
      url: kinveyBaseUrl + '/user/' + kinveyAppKey,
      headers: kinveyAppAuthHeaders,
      data: userData,
      success: registerSuccess,
      error: handleAjaxError
    });

    function registerSuccess(userInfo) {
      saveAuthInSession(userInfo);
      showInfo("User Successfully Registered");
    }

The Question is:

How can i bind and when i clicked "Register" button it runs correctly and register a user. Here is the Register.html fail

  • 写回答

3条回答 默认 最新

  • weixin_33725239 2016-12-13 13:05
    关注

    You can bind registerUser function with your submit button simply by using jQuery on() method:

    $(document).ready(function() {
        $('#reg-btn').on('click', registerUser);
    });
    

    But it's better to bind on form's submit event:

    $(document).ready(function() {
        $('#your-form').on('submit', registerUser);
    });
    

    but in that case you have to return false at the end of the your registerUser function in order to prevent default submit behaviour.

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料