Link to home
Start Free TrialLog in
Avatar of flynny
flynnyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

creating generic ajax method

hi all,

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"
    });
}

Open in new window


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
Avatar of jayakrishnabh
jayakrishnabh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial