Need help on server ajax

Need help on server ajax

goodguycannongoodguycannon Posts: 12Questions: 0Answers: 0
edited September 2009 in General
I spent the last 4 hours try to get this to work. Please take a quick look and let me know what the problem may be.

It appears that the web page is never making a request to the server for the data:
[code]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">




@import "lib/dataTables-1.5/media/css/demo_table.css";






$(document).ready(function(){

$('#test).dataTable({
"bProcessing": true,

"sAjaxSource": "http://whatalife.com/server/request.php?cmd=docs"
});

});

New Web Project


New Web Project Page




[/code]

Replies

  • allanallan Posts: 61,708Questions: 1Answers: 10,102 Site admin
    edited September 2009
    Hi,

    Line 15:

    [code]
    $('#test).dataTable({
    [/code]
    should be:

    [code]
    $('#test').dataTable({
    [/code]
    I'd be surprised if a Javascript debugger didn't throw an error for that... Which debugger are you using?

    Allan
  • goodguycannongoodguycannon Posts: 12Questions: 0Answers: 0
    Hi Allan. I am using Aptana editor, and firefox for testing.

    I dont see that syntax in any of the examples. Where do you close that bracket?

    Dave.
  • allanallan Posts: 61,708Questions: 1Answers: 10,102 Site admin
    Hi Dave,

    Sorry about that - my finger much have hit the brace key when I hit return... That wasn't meant to be there, and I've removed it now. The key thing was that your string quoted string for '#test' doesn't have a closing single quote. You should be able to see this from the syntax highlighting above.

    Are you using Firebug with Firefox, or checking the javascript error console? I'd expect that error to show up there.

    Regards,
    Allan
  • goodguycannongoodguycannon Posts: 12Questions: 0Answers: 0
    edited September 2009
    I must have missed the quote when I changed the variable name when I posted, it is actually in there.

    I validated the ajax (from the url above) with ajaxlint.

    I have both firebug and the error console up, and I do not get an error. Still with the quote in there, I dont see a request from the browser to the ajax service. Any other ideas?

    Dave.
  • allanallan Posts: 61,708Questions: 1Answers: 10,102 Site admin
    Hi Dave,

    Okay - that rules out one thing then :-). The next finger of suspeision is going to point at he Ajax source. Is "whatalife.com" the domain that your DataTables is running on? If not, then I think you are going to be running into troubles with Cross Site Scripting (XSS) protection in the browser: http://datatables.net/forums/comments.php?DiscussionID=603

    Can you load an Ajax source using a relative URL, rather than an absolute one? That would confirm if this is the case.

    Regards,
    Allan
  • goodguycannongoodguycannon Posts: 12Questions: 0Answers: 0
    Thanks fAllan, thanks for taking the time to get me started.

    I decided to install Xampp on my development machine, and all is working now.

    It would appear that a relative URL was the problem.

    Dave.
  • allanallan Posts: 61,708Questions: 1Answers: 10,102 Site admin
    Hi Dave,

    Good stuff. Funny that the browser didn't report an XSS attempt, but I've noticed that Firebug/Firefox isn't reporting errors with the same degree of accuracy as it used to with the current iterations. Hopefully they will update the tools sometime soon.

    If you do need to support Cross Site Scripting, then you might want to look into using YUI's connection manager (there might be something similar for jQuery). YUI use Flash to get around the XSS protection in browsers.

    Regards,
    Allan
This discussion has been closed.