Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ajax调用中的解析器错误_Ajax - Fatal编程技术网

Ajax调用中的解析器错误

Ajax调用中的解析器错误,ajax,Ajax,我试图通过Ajax调用从html页面调用controller方法,脚本如下: <script> $.ajax({ url: '/Controllet/getAuth', type: "Post", data: { token: "skgdajshdgfyvbjgydsa", userId: "user1" }, cache: fa

我试图通过Ajax调用从html页面调用controller方法,脚本如下:

<script>
    $.ajax({
        url: '/Controllet/getAuth',
        type: "Post",
        data: {
            token: "skgdajshdgfyvbjgydsa",
            userId: "user1"
              },
            cache: false,
            dataType: "json",
            async: true,
            contentType: false,
            processData: false,
            success: function (response) {
                if (response != null && response.success) {
                    alert(response.responseText);        
                } else {
                    //do something else
                }
            },
            error: function (xhr, status, err) {
                alert('Response code:' + xhr.status);
                alert('[Error:' + err + '] ' + status);
            }
        });

$.ajax({
url:“/Controllet/getAuth”,
类型:“Post”,
数据:{
令牌:“skgdajshdgfyvbjydsa”,
userId:“user1”
},
cache:false,
数据类型:“json”,
async:true,
contentType:false,
processData:false,
成功:功能(响应){
if(response!=null&&response.success){
警报(response.responseText);
}否则{
//做点别的
}
},
错误:函数(xhr、状态、错误){
警报(“响应代码:”+xhr.status);
警报('[错误:'+err+']'+状态);
}
});
我的控制器方法如下所示

private async Task<JsonResult> GetAuth(string token, string userId)
{
    try
    {
        //do something
        return Json(new { success = true, responseText = "!" },
        JsonRequestBehavior.AllowGet);
    }
    catch (Exception ex)
    {
        return Json(new { success = false, responseText = " "
        + ex.Message }, JsonRequestBehavior.AllowGet);
    }
}
private async Task GetAuth(字符串令牌、字符串用户标识)
{
尝试
{
//做点什么
返回Json(新的{success=true,responseText=“!”},
JsonRequestBehavior.AllowGet);
}
捕获(例外情况除外)
{
返回Json(新的{success=false,responseText=“”
+例如Message},JsonRequestBehavior.AllowGet);
}
}
每次运行此命令时,我都会得到[Error:SyntaxError:Unexpected token<在JSON中的位置2]parserror