javascript - pass array in the "data" tag at server side - bootstrap ajax call -


i not able figure out if can send array in data tag: client js code looks :

                     $.ajax({         url: '/mobiledoc/jsp/aco/beneficiary/ptmmview.jsp',         data: {             "action":"savepatientrecords",             "ptid":strptid,             "patientval":patientval,             "qid":qid,             "qtype":qtype                             "array" : ??         },         datatype: 'text',         type: 'post',         success: function (responsemsg) {         // gets response message server             loadmilestonedata();             alert(responsemsg);        

yes can. first use method instead of type post. this...

method: 'post' 

jquery should serialise data you.

$.ajax({     url: '/mobiledoc/jsp/aco/beneficiary/ptmmview.jsp',     data: {         "action": "savepatientrecords",             "ptid": strptid,             "patientval": patientval,             "qid": qid,             "qtype": qtype,             "array": [ 1, 2, 3 ]     },     datatype: 'text',     method: 'post',     success: function (responsemsg) {         // gets response message server         loadmilestonedata();         alert(responsemsg);     } }); 

if not, use json.stringify turn objects/arrays string.

$.ajax({     url: '/mobiledoc/jsp/aco/beneficiary/ptmmview.jsp',     data: json.stringify({         "action": "savepatientrecords",             "ptid": strptid,             "patientval": patientval,             "qid": qid,             "qtype": qtype,             "array": [ 1, 2, 3 ]     }),     datatype: 'text',     method: 'post',     success: function (responsemsg) {         // gets response message server         loadmilestonedata();         alert(responsemsg);     } }); 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -