How can I get a simple, single string from an ajax call? Normally I have been having the Controller return a result set of items via a Model like this...
var parmObject = JSON.stringify({
'p_db_type': db_type,
'p_sch': sch,
'p_own': own,
'p_env': env,
'p_baseline': baseline,
'p_view_type': view_type,
'p_last_days': last_days,
'p_refresh_job_type': meta_refresh_type,
});;
$.ajax({
url: "/SchemaTree/get_average_wait_time?p_db_type=" + db_type + "&p_sch=" + sch + "&p_own=" + own + "&p_env=" + env + "&p_baseline=" + baseline + "&p_view_type=" + view_type,
type: 'POST',
beforeSend: function () {
$("#please_wait_box").show();
},
async: true,
dataType: 'json',
contentType: 'application/json',
data: parmObject,
success: function (data) {
$.each(data, function (i, item) {
//do stuff with the item...
})
},
error: function (result) {
alert("AJAX (st) Error: " + result.error);
}
});
but when I have the Controller return a single string, the above success function gets syntax error...
JavaScript runtime error: Invalid operand to 'in': Object expected
Thanks much if you can advise.