1

Am trying to send integer type data in json and retrive in server side

in client side am sending in below code

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')
    }
  });

And in server side while i trying to print data am getting as

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

actually am sending id as integer format but in server side am getting this as string.

How can i retrive { id: 1, password: 'qwer' }.i want to pass this data to update a database.so i cant change it as { id: parseInt('1'), password: 'qwer' }. In database id are stored in integer form.so due this problem cant update the db also.

helper.update(context.db.Signups, data,  function(err, res) {
console.log(res)
 callback(null, {res:true});
 });
1
  • why can't you parse it to int on the server side ? Commented Jun 18, 2014 at 7:02

1 Answer 1

1

you can add processData : false to the options section of your .ajax call.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.