发送json中的整数types参数作为使用jQuery的ajax请求

我试图在json中发送整数types的数据,并在服务器端回顾

在客户端发送下面的代码

var userID = readCookie("user_id"); var data = { "id": parseInt(userID), "password": $("#password").val() }; $.ajax({ type: 'post', url: "/changePassword", dataType: "json", data: data, success: function (response) { $("#errLabel").html('Password changed successfully') } }); 

而在服务器端,而我试图打印数据越来越

  { id: '1', password: 'qwer' } 

实际上是发送id为整数格式,但在服务器端我得到这个string。

我怎么能retrive { id: 1, password: 'qwer' } 。我想通过这个数据来更新database.so我不能改变它为{ id: parseInt('1'), password: 'qwer' }. 在数据库ID存储在整数forms。因此,这个问题也不能更新db

 helper.update(context.db.Signups, data, function(err, res) { console.log(res) callback(null, {res:true}); }); 

您可以将processData:false添加到.ajax调用的选项部分。