Вопрос

I have an AJAX.RouteLink which has the following AJAXOptions

new AjaxOptions
            {
                HttpMethod = "POST",
                OnFailure = "OnFailure",
                OnSuccess = "OnSuccess"
            })

My OnFailure method looks like this

function OnFailure(ajaxContext) {
        var response = ajaxContext.get_response();
        var statusCode = response.get_statusCode();

        var elem = document.getElementById('message');
        elem.innerHTML = 'Sorry, the request failed with status code' + statusCode;
    }

Problem is, when it gets called I get this error

TypeError: ajaxContext.get_response is not a function

In the watch list I can see that the responseText in ajaxContext is html.

What am I doing wrong here?

Это было полезно?

Решение

The problem was that ajaxContext doesn't have a get_response method. It must be an old version of the object whose example I was looking at.

Since I wanted the status code, I just used the ajaxContext.status property.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top