Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.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
Javascript 正在获取错误。。。{readyState:4,getResponseHeader:ƒ;,GetAllResponseHeader:ƒ;,setRequestHeader:ƒ;,OverrideMetype:ƒ;,…}django_Javascript_Django_Ajax - Fatal编程技术网

Javascript 正在获取错误。。。{readyState:4,getResponseHeader:ƒ;,GetAllResponseHeader:ƒ;,setRequestHeader:ƒ;,OverrideMetype:ƒ;,…}django

Javascript 正在获取错误。。。{readyState:4,getResponseHeader:ƒ;,GetAllResponseHeader:ƒ;,setRequestHeader:ƒ;,OverrideMetype:ƒ;,…}django,javascript,django,ajax,Javascript,Django,Ajax,我已经创建了一个ajax函数来接受我的项目请求,但是当我试图接受它时,它给了我200,但什么也不做,并且在我的ajax中出错 这是我的ajax function acceptMatchRequest(match_request_id, uiUpdateFunction){ var url = "{% url 'accept-match-request' match_request_id=53252623623632623 %}".replace(&quo

我已经创建了一个ajax函数来接受我的项目请求,但是当我试图接受它时,它给了我200,但什么也不做,并且在我的ajax中出错

这是我的ajax

   function acceptMatchRequest(match_request_id, uiUpdateFunction){
        var url = "{% url 'accept-match-request' match_request_id=53252623623632623 %}".replace("53252623623632623", match_request_id)
        $.ajax({
            type: 'GET',
            dataType: "json",
            url: url,
            timeout: 5000,
            success: function(data) {
                console.log("SUCCESS", data)
                if(data['response'] == "Match request accepted."){
                    // ui is updated
                }
                else if(data['response'] != null){
                    alert(data['response'])
                }
            },
            error: function(data) {
                console.error("ERROR...", data)
                // console.log(data)
                alert("Something went wrong.")
            },
            complete: function(data){
                uiUpdateFunction()
                console.log(data)
            }
        });
    }
这是我的JS

  function onMatchRequestAccepted(){
    location.reload();
  }

  function triggerAcceptMatchRequest(match_request_id){
    acceptMatchRequest(match_request_id, onMatchRequestAccepted)
  }
我的观点

def accept_match_request(request, *args, **kwargs):
    user = request.user
    print(user)
    payload = {}
    if request.method == "GET" and user.is_authenticated:
        match_request_id = kwargs.get("match_request_id")
        if match_request_id:
            match_request = MatchRequest.objects.get(id=match_request_id)
            # confirm that is the correct request
            if match_request.receiver == user:
                print(match_request)
                if match_request:
                    # found the request. Now accept it
                    match_request.accept()
                    payload['response'] = "Match request accepted."
                else:
                    payload['response'] = "Something went wrong."
            else:
                payload['response'] = "That is not your request to accept."
        else:
            payload['response'] = "Unable to accept that Match request."
    else:
        # should never happen
        payload['response'] = "You must be authenticated to accept a Match request."
    return HttpResponse(json.dumps(payload), content_type="application/json")
我得到的错误如下。

点击ok后,我得到这个

我在python终端中没有收到任何错误

我得到下面的数据,在我的对象中返回的是我的另一个模块的HTTP响应,它在这个模块中作为响应文本出现,我不知道为什么会发生这种情况


请向我们显示完整错误。已更新错误而不是跟踪,实际扩展的错误。在错误回调中执行
控制台。错误(参数[2])并发布结果第二个是扩展跟踪,这就是我得到的所有结果