$.ajax({
    url: "/Configuration/AddServersAdvancedSelect",
    type: "POST",
    data: { selectedOUs: that.getByDataSelected() },
    async: false,
    dataType: "html",
    success: result => {
        cont.setTabContentFromHtmlString(result, 1);
        cont.tabClicked($("td[data-value='1']").get(0));
    },
    error: (xhr, ajaxOptions, thrownError) => {
        //
    }
});

This is my ajax request towards the server. For some reason the data doesn't get selected. The getByDataSelected function works just like it should and reuturns good values. The Controller method has the name selectedOUs and everything matches. Does anybody have any idea as to why this ajax POST doesn't send data?

jQuery defines the data parameter as

Type: PlainObject or String or Array

Data to be sent to the server. It is converted to a query string, if not already a string. It's appended to the url for GET-requests. See processData option to prevent this automatic processing.

Object must be Key/Value pairs.

If value is an Array, jQuery serializes multiple values with same key based on the value of the traditional setting (described below).

I'd be willing to bet that your return value of that.getByDataSelected() is not consistent with the expected parameter if it isn't getting sent.

In this case, your error function should be receiving an Internal Server Error [500]

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.