I have an API integartion where the SMS service wants us to send data in this format with content-type as json.
{
"from": "91887654681",
"to": ["918757077777"],
"body": "Hi this is my message using Mblox SMS REST API"
}
I have a form with input texts namely from, to and body.
This is how my form submits.
$("#sendSMSForm").submit(function(event){
event.preventDefault();
// Serialize the form data.
var form = $('#sendSMSForm');
var formData = $(form).serialize();
//alert(formData);
$.ajax({
type: 'POST',
dataType: 'json',
contentType: "application/json",
url: $(form).attr('action'),
data: formData
}).done(function(response) {
// Do some UI action stuff
alert(response);
});
});
I am not sure ...what should be used to pass a similar format.... of which the "to" is an array.