I have a small issue: I need to pass the value of string from function A to function B which will take it as argument and use it.
I have tried the following but its not working.
// first function (A)
$("a#SayHello").click(function (e) {
e.preventDefault();
var x = function () {
var dt = '{"ProductID": "' + $("input#ProductID").val() + '" , "AffiliationURL": "' + $("input#AffiliationURL").val() + '" , "Quantitiy": "' + $("input#Quantitiy").val() + '" , "PricePerUnit": "' + $("input#PricePerUnit").val() + '" , "commissionAmount": "' + $("input#commissionAmount").val() + '"}';
return dt.toString();
};
alert(x);
$.B(x);
});
// second function
function B(dt) {
$.ajax({
type: 'POST',
data: dt,
url: 'http://localhost:4528/WebSite1/WebService.asmx/InsertCommissionRecord',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (data, textStatus, XMLHttpRequest) {
alert(data.d);
alert(XMLHttpRequest);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
}
});
};