flynny
asked on
creating generic ajax method
hi all,
I am trying to create a generic AJAX method for calling on a site
the above code works fine, however when I substitute username to fieldname (i.e. to the passed variable, the method doesnt fire?
Is there anyway I can inject the fieldname text into this method?
thanks.
I am trying to create a generic AJAX method for calling on a site
function runAjax(webmethod, fieldname, fieldtext) {
return $.ajax({
type: "POST",
url: webmethod,
data: JSON.stringify({ username: fieldtext }),
contentType: "application/json; charset=utf-8",
dataType: "json"
});
}
the above code works fine, however when I substitute username to fieldname (i.e. to the passed variable, the method doesnt fire?
Is there anyway I can inject the fieldname text into this method?
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.