Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried the below code. but its not working

What I have tried:

JavaScript
$(document).ready(function() {  


loadMyItems();
    
})


function loadMyItems() {  
    var siteUrl = _spPageContextInfo.siteAbsoluteUrl;  
    alert(siteUrl);
    var oDataUrl = siteUrl + "/_api/web/lists/getbytitle('Purchase Order')/items?$select=PO_x0020_ID";  
    $.ajax({  
        url: oDataUrl,  
        type: "GET",  
        dataType: "json",  
        headers: {  
            "accept": "application/json;odata=verbose"  
        },  
        success: mySuccHandler,  
        error: myErrHandler  
    });  
}  
function mySuccHandler(data){

 try{  
        var dataTableExample = $('#table_id').DataTable();  
        if (dataTableExample != 'undefined') {  
            dataTableExample.destroy();  
        } 
        
        
        dataTableExample = $('#table_id').DataTable({  
            scrollY: 300,  
            "aaData": data.d.results,  
            "aoColumns": [{  
                "mData": "PO_x0020_ID"  
               
            }]  
        });
             
        }
        catch (e){
        alert ("e.message");
        }
        }
        
  
function myErrHandler(data ,errCode, errMessage) {  
    alert("Error: " + errMessage);  
}
Posted
Updated 9-Nov-17 18:28pm
v2
Comments
Karthik_Mahalingam 9-Nov-17 8:39am    
are you getting any error ?
Member 13512216 10-Nov-17 0:40am    
no error occured..column value is not passing in the html table..
Karthik_Mahalingam 10-Nov-17 0:43am    
are you getting the data from success event ?
Member 13512216 10-Nov-17 0:44am    
yes
Karthik_Mahalingam 10-Nov-17 1:19am    
show the sample json data.

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