2

I have four ajax calls for four columns, plus some radio buttons for custom query, now on every each selected radio which corresponds to the ajax calls I need the fetched data to be added to the correct column of Datatables, so far, I wrote it like below but it doesn't work.

   get_available_prefix_request(id, datatable_search){
    fetch(`${this.url['get_available_prefix']}/${id}`)
        .then(response => response.json())
        .then(data => {
            data.forEach(x => {
                datatable_search.row.add(x['address'], '', '', '').draw();
            })
        });
}

get_unavailable_prefix_request(id,datatable_search){
    fetch(`${this.url['get_unavailable_prefix']}/${id}`)
        .then(response => response.json())
        .then(data => {
            data.forEach(x => {
                datatable_search.row.add('', x['address'], '', '').draw();
            })
        });
}

get_unavailable_ip_addresses_request(id, datatable_search){
    fetch(`${this.url['get_unavailable_ip_addresses']}/${id}`)
        .then(response => response.json())
        .then(data => {
            data.forEach(x => {
                datatable_search.row.add('', '', x['address'], '').draw();
            })
        });
}

get_available_ip_addresses_request(id, datatable_search){
    fetch(`${this.url['get_available_ip_addresses']}/${id}`)
        .then(response => response.json())
        .then(data => {
            data.data.forEach(x => {
                datatable_search.row.add('', '', '', x['address']).draw();
            })
        });
}

I would appreciate any help, thanks in advance.

1 Answer 1

1

You just need to put your values into square brackets:

datatable_search.row.add(['', '', '', x['address']]).draw();
Sign up to request clarification or add additional context in comments.

Comments

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.