如何使用jquery发布输入数据变量

How to post input data variables with jquery

本文关键字:输入 数据 变量 何使用 jquery 布输入      更新时间:2023-09-26
$(document).ready(function(){
  $(".submit").click(function() {
    var emailVal = $(".email").val()
    $.ajax({ type: 'POST',
             url: 'settings/update',
             data: { email: emailVal },
             beforeSend:function(){
                //loading image
                $('#ajax-panel').html('<div class="loading"><img src="/images/ajax-loader.gif" alt="Loading..." /></div>');
             },
             success:function(data){
                 // successful request; do something with the data
                 $('#ajax-panel').empty();
                 $('#ajax-panel').html(data);     
             },
             error:function(){
                 // failed request; give feedback to user
                 $('#ajax-panel').html('<p class="error"><strong>Oops!</strong> Try that again in a few moments.</p>');
             }
          });
        });
      });

emailVal变量没有作为post数据发送。我的语法有问题吗?

本行末尾缺少分号

var emailVal = $(".email").val()