What am I doing wrong?

What am I doing wrong?

webdad3webdad3 Posts: 7Questions: 0Answers: 0
edited October 2010 in General
I'm trying to load the data into the datatable from a webservice that returns the data in JSON format. I keep getting errors here:

oTable.fnAddData(["" + data.ListExercise[i].exercise_id, data.ListExercise[i].exercise_value]);
or oTable is undefined.

What am I doing wrong?

Here is my code:


<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="MyFitnessApp._Default" %>














Exercise ID
Exercise Value








Below is my dataTable.js file:

function loadData() {
$.ajax({
url: "../webService/exercise_ws.asmx/ExerciseGet",
data: "{}",
success: function (data) {

for (var i = 0; i < data.ListExercise.length; i++) {
alert(i);
var eVal = data.ListExercise[i];
$('#example').dataTable.fnAddData(["" + data.ListExercise[i].exercise_id, data.ListExercise[i].exercise_value]);
}
}
});
}
$(document).ready(function () {

$.ajaxSetup({
type: "POST",
contentType: "application/json; charset=utf-8",
data: "{}",
dataFilter: function (data) {
var msg;

if (typeof (JSON) !== 'undefined' &&
typeof (JSON.parse) === 'function')
msg = JSON.parse(data);
else
msg = eval('(' + data + ')');

if (msg.hasOwnProperty('d')) {
return msg.d;
} else {
return msg;
}
}
});

loadData();
});

Replies

  • webdad3webdad3 Posts: 7Questions: 0Answers: 0
    I figured out what the issue was. I had the jquery.js file and the jquery1.4.1.js file both referenced in the same page. It didn't like that.
This discussion has been closed.