This uses jQuery ajax to submit a JAVASCRIPT object - converted to a JSON string - to a web service
Code:
function ctrlWebService(strOpt, strVal1, strVal2, strId) {
var objWebParam = {};
objWebParam.username = window.username || "";
objWebParam.ctrloption = strOpt;
objWebParam.ctrlval1 = strVal1;
objWebParam.ctrlval2 = strVal2;
var strWebParam = $.toJSON(objWebParam);
$.ajax({
type: "POST",
url: "WebService.asmx/CtrlService",
dataType: "json",
data: strWebParam,
contentType: "application/json; charset=utf-8",
success: function(msg) {
ajaxCtrlFinished(msg, strId, {});
},
failure: function(msg) {
ajaxCtrlFinished(msg, "failure", {});
},
error: function(msg) {
ajaxCtrlFinished(msg, "error", {});
}
});
}
The webservice is declared like this
Code:
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False)> _
Public Function CtrlService(ByVal ctrloption As String, ByVal ctrlval1 As String, ByVal ctrlval2 As String, ByVal username As String) As String
If one of the object pairs was more complex then just a string value you can have the web service declared in these other various ways
Code:
Public Function AddService(ByVal toddtype As String, ByVal fromddtype As String, ByVal fromwho As String _
, ByVal objReturn As Dictionary(Of String, String) _
objReturn is a OBJECT datatype from the client side...
Code:
Public Function OperatorService(ByVal toddtype As String, ByVal fromddtype As String, ByVal fromwho As String _
, ByVal newkeys As IList(Of String) _
, ByVal updkeys As IList(Of String) _
, ByVal editkey As String _
, ByVal username As String _
, ByVal objReturn As Dictionary(Of String, String)) As String
newkeys and updkeys are ARRAYS of strings from javascript client side
Code:
, ByVal source As IList(Of Dictionary(Of String, String))
source is an ARRAY of JS OBJECTS.
That pretty much covers all the datatype combinations in JAVASCRIPT - all coming in as nice handy to use datatypes in VB.
Hope that was your question!!!