Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

REST script error

I get the following error with the code below: Error: Unable to get property 'Title' of undefined or null reference


function getListItems(url, listname, complete, failure) {

    // Executing our items via an ajax request
    $.ajax({
        url: url + "/_api/web/lists/getbytitle('" + listname + "')/items",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            complete(data); // Returns JSON collection of the results
        },
        error: function (data) {
            failure(data);
        }
    });
	
 function complete(data) {
    var truckPie = new truck2pie();
	
	for (i=0;i<=data.d.results.length; i++)
	 {  	 
	  console.log(data.d.results[i].Title);
	  truckPie.addTruck([b]data.d.results[i].Title[/b],  data.d.results[i].NumberOfTrucks);  //<---
	 }
 }
 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial