Click here to Skip to main content
15,742,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to pass jquery data values to another page's form. I've tried the suggested solutions I found in the net but still no luck.

The solution I am thinking is to add the data to my href and from there extract the values and add to my fields.

What I have tried:

Here is the code I tried but failed:

<pre>$(document).ready(function () {
    dataTable = $('#DT_employees').DataTable({
        "pageLength": 50,
        "ajax": {
            "url": "/api/Employees",
            "type": "GET",
            "datatype": "json"
        "columns": [
            { "data": "employeeId", "width": "10%" },
            { "data": "userName", "width": "10%" },
            { "data": "firstName", "width": "10%" },
            { "data": "lastName", "width": "10%" },
                "data": "{employeeId, firstName, lastName}",
                "render": function (data) {
                    return `<div class="w-75 btn-group">
                                <a href = "/Trainees/Index?=${data}" class="btn btn-primary text-white">
                "width": "5%"
        "width": "100%"
Updated 17-Apr-23 0:34am

1 solution

Your code doesn't attempt to pass any data to the /api/Employees endpoint.

The manual has an example of how you would do that:[^]

"ajax": {
    "url": "/api/Employees",
    "type": "GET",
    "data": function ( d ) {
        d.extra_search = $('#extra').val();

Since you're making a GET request, the data will be passed in the querystring. If you want to pass the data in the body instead, then change your endpoint and your datatable configuration to use a POST request instead.
Share this answer
Markeeh 18-Apr-23 0:06am    
Thanks @Richard Deeming!
This was also answered in

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900