我试图通过AJAX将超过1个值传递给VB.NET。
我目前正在传递1个完全正常的值但是当我尝试第二个时它出错了。
var form = document.getElementById("OrderForm"),
inputs = form.getElementsByTagName("input"),
value = [],
name = [];
for (var i = 0, len = inputs.length; i < len; i++) {
if (inputs[i].type === "hidden") {
value.push(inputs[i].value)
name.push(inputs[i].name)
if (value[i] !== "") {
console.log(name[i], " = ", value[i]);
//args = '{"value":"' + arr[i] + '"Name":"' + arr[i] + '"}';
//args = '{"Value":"' + value[i] + '"}';
//args = 'Name=' + name[i] + '&Value=' + alue[i];
args = '{ "Value":' + value[i] + ', "Value":' + value[i] + '}'
aj('payment', returnFunc, args, failedCallBack);
}
}
}
function aj(funcName, retFunc, arguments, failedCallBack) {
var retval;
var funcName = funcName;
retval = $.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: '../PaymentGateway.asmx/' + funcName,
data: arguments,
processData: false,
dataType: "json",
success: retFunc,
error: function (a, b, c) {
if (c == 'Unauthorized') {
//ShowErrorMSG('Error, please login again', a.responseText);
} else if (c != 'abort') {
}
}
});
return retval;
}
function failedCallBack(res) {
}
我将它们传递给我的VB.NET函数。
Public Function payment(Value As String, Name As String) As String
答案 0 :(得分:0)
传递的参数不正确。
args = '{"Value":"' + value + '", "Name":"' + name + '"}';
是正确的方法。