如何确定返回的Json是一个简单的字符串还是编码对象--jQuery

时间:2018-05-10 21:15:53

标签: jquery asp.net-mvc-5

有没有办法确定控制器是否正在发回一个简单的Json字符串或编码对象?

如果信息正确返回,它将作为编码对象发送......

Return Json(vResult, JsonRequestBehavior.AllowGet)

但是有一个例外是一个简单的字符串......

Return Json(UnhandledError)

如何查看返回的内容?

像这样的东西

success: function (response) {
if (response is Json object) { // This is the problem bit
                $('#textareaDescription').val(response.Description);  
            }
            else {
              ModalError(response);


            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            ModalError(textStatus + " - " + errorThrown);
        }

谢谢

0 个答案:

没有答案
相关问题