see no data request using ajax

see no data request using ajax

dinotomdinotom Posts: 27Questions: 7Answers: 0

given the following snippet, I get no table. Watching Fiddler, I never see a data request. The service url works when used in browser, so that's not the issue. (ideaTable is the variable that holds the table selector)

[code]
$('#btnShowIdeas').on('click', function(e) {
e.preventDefault();
ideaTable.dataTable({
"bServerSide": true,
"sAjaxSource": "http://localhost:54594/api/Ideas/GetTodaysIdeas",
"aoColumns": [{
"mData":"CompanyInfo",
"sTitle": "Company"
},{
"mData":"TradeDirection",
"sTitle": "Buy/Sell"
}, {
"mData": "Notes",
"sTitle": "Trading Notes"
}]
});
[/code]

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    We'd need a link to the page showing the issue so we can understand what is going wrong. Are at least a debugger trace ( http://debug.datatables.net ).

    Allan

  • dinotomdinotom Posts: 27Questions: 7Answers: 0
    edited May 2014

    Ok I had a glitch in my html as it pertained to the table. That is fixed and now the initialization code is hitting fiddler and return the results but they are not bound to the columns. Am I defining the columns incorrectly? The data comes back as an json array of objects as shown <br />
    [{<br />
    "Symbol":null,
    "CompanyInfo":"Alcatel Lucent (ALU)",
    "id":0,
    "Date":"2014-05-09T00:00:00-04:00",
    "symbolId":0,
    "TradeDirection":"Buy",
    "Notes":"Very Positive Q1 results",
    "WasTradeEntered":null,
    "WasTradeSuccessful":null,
    "EntryPrice":null,
    "ExitPrice":null<br />
    },{<br />
    "Symbol":null,
    "CompanyInfo":"Tesla Motors (TSLA)",
    "id":0,
    "Date":"2014-05-09T00:00:00-04:00",
    "symbolId":0,
    "TradeDirection":"Buy",
    "Notes":"Continuation short on negative comments",
    "WasTradeEntered":null,
    "WasTradeSuccessful":null,
    "EntryPrice":null,
    "ExitPrice":null<br />
    }]

  • dinotomdinotom Posts: 27Questions: 7Answers: 0
    edited May 2014

    And the html for the table is is defined with three headers and an empty tbody. I tried putting the html in this comment but it only showed the header titles

  • dinotomdinotom Posts: 27Questions: 7Answers: 0

    I also tried it 1.10 way using the following <br />
    [code]<br />
    ideaTable.DataTable({<br />
    "ajaxSource": "http://localhost:54594/api/Ideas/GetTodaysIdeas",<br />
    "columns": [<br />
    { "data": "CompanyInfo" },<br />
    { "data": "TradeDirection" },<br />
    { "data": "Notes" }<br />
    ]<br />
    });<br />
    [/code]<br />

    and again, it hits Fiddler, I receive the json back but now the Loading... just sits there and no data is bound

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    edited May 2014

    Allan already said this:

    We'd need a link to the page showing the issue so we can understand what is going wrong. Or at least a debugger trace ( http://debug.datatables.net ).

    Allan

  • dinotomdinotom Posts: 27Questions: 7Answers: 0

    Well the page is in development, not live so that's not possible. I'll try to host a single page site for it

  • dinotomdinotom Posts: 27Questions: 7Answers: 0

    I sorted out the problem.

This discussion has been closed.