0

I'm getting the error Uncaught ReferenceError: GetLicenceUserList is not defined in the browser console when I call the function using $.ajax function inside.

But the call of my function works just fine when I call it with only an alert("example"); inside.

This are the code of both examples.

function GetLicenceUserList(id, actPage = 1, actualSearch = "", colOrder = 2, colDirec = "desc") {

alert(id + " - " + actPage + " - " + actualSearch + " - " + colOrder + " - " + colDirec);

/*$.ajax({
    url: "/Licences/UserLicenceList",
    type: "POST",
    data: {
        userId: id,
        actPage = actPage,
        actualSearch = actualSearch,
        colOrder = colOrder,
        colDirec = colDirec
    }
}).done(function (result) {
    $("#userLicence-list-card").html(result);
    alert("ok");
}).fail(function () {
    //operaciones en caso de falla
    alert("fail");
});*/
}

This one works great, and the following is where the error occurs (when uncomment the ajax call):

function GetLicenceUserList(id, actPage = 1, actualSearch = "", colOrder = 2, colDirec = "desc") {

//alert(id + " - " + actPage + " - " + actualSearch + " - " + colOrder + " - " + colDirec);

$.ajax({
    url: "/Licences/UserLicenceList",
    type: "POST",
    data: {
        userId: id,
        actPage = actPage,
        actualSearch = actualSearch,
        colOrder = colOrder,
        colDirec = colDirec
    }
}).done(function (result) {
    $("#userLicence-list-card").html(result);
    alert("ok");
}).fail(function () {
    //operaciones en caso de falla
    alert("fail");
});
}
3
  • idownvotedbecau.se/imageofcode Commented Apr 13, 2021 at 18:04
  • @Jejun sorry, fixed :D Commented Apr 13, 2021 at 18:11
  • 4
    Use a tool like eslint or jshint. You've made a few (identical) typos and generated a syntax error. Object literals use key: value pairs, not key = value pairs. Commented Apr 13, 2021 at 18:13

1 Answer 1

1

Your data object is not defined correctly in $ajax

You are using equals signs (=) instead of colons (:).

The data object should be like this instead:

data: {
        userId: id,
        actPage: actPage,
        actualSearch: actualSearch,
        colOrder: colOrder,
        colDirec: colDirec
    }
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! this was the problem :)

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.