0

I have a partial view that I'm trying to use an AJAX GET request on.

Her is the function that's calling the controller. Through debugging I've found that it hits the controller correctly, the controller works properly, but then the updated target is never updated. So I believe it's how this function is written that's the issue. Is there an issue with the datatype being "json"? I can't figure this out. Note that I'm setting the parameter to "user1" for debugging since i know there's a user1.

function searchUsers(searchTerm) {
    var confirmation = confirm(searchTerm);
    if (confirmation == true) {
        var param =
        {
            searchTerm: "user1"
        };
        $.ajax({
            url: "/Home/SearchUsers/",
            type: "GET",
            datatype: "json",
            async: true,
            data: param,
            error: function (xmlHttpRequest, errorText, thrownError) {
                alert(xmlHttpRequest + "|" + errorText + "|" + thrownError);
            },
            success: function (data) {
                if (data != null) {
                    $("#updateTable").html(data);
                }
            }
        });
    }
}
2
  • That looks fine to me.. Maybe try adding a contentType? e.g. contentType: "application/json; charset=utf-8" and remove the async
    – mnsr
    Jan 22, 2014 at 3:58
  • Is it hitting your success function? Can you add a console.log() to both success and error to check. Can you console.log(data) to see what is returned
    – jammykam
    Jan 22, 2014 at 4:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.