0

how to send parameter? [{'b':0,'c':1,'d':2},{'b':1,'c':2,'d':3},{'b':2,'c':3,'d':4}]

var a=[x,y,z];
for(i = 0; i < a; i++){
    var b = i;
    var c = i+1;
    var d = i+2;
};

$.ajax({
      type:"post",
      url: "http://192.168.34.211:8081/save",
      dataType: "json",
      data: .... ?   //[{'b':0,'c':1,'d':2},{'b':1,'c':2,'d':3},{'b':2,'c':3,'d':4}]
      success: function( data ) {

      }
 });
2
  • What have you tried so far? You should probably turn it into a string with JSON.stringify or alike Commented May 24, 2018 at 6:55
  • Possible duplicate of Jquery Ajax Posting json to webservice Commented May 24, 2018 at 7:05

1 Answer 1

1

You can try with JSON.stringify

var a=[x,y,z];
for(i = 0; i < a; i++){
    var b = i;
    var c = i+1;
    var d = i+2;
};

$.ajax({
      type:"post",
      url: "http://192.168.34.211:8081/save",
      contentType: 'application/json'
      data: JSON.stringify(postData)   //[{'b':0,'c':1,'d':2},{'b':1,'c':2,'d':3},{'b':2,'c':3,'d':4}]
      success: function( data ) {

      }
 });

I hope this will helps you.

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.