Help with POST requests

Help with POST requests

steveocsteveoc Posts: 9Questions: 0Answers: 0
edited August 2011 in General
Hi,

I'm moving my DataTables fro GET to POST requests.

Using the following code:

"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "q", "value": "undefined"});
$.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback


I get valid JSON returned and the table fills as expected.

However when I change the type to POST, I still get the JSON returned but table fails to draw. No errors just the ProcessingIndicator

All help gratefully accepted.

Thanks

Replies

  • steveocsteveoc Posts: 9Questions: 0Answers: 0
    Update:

    The only difference between the JSON returned by GET and POST methods is the sEcho parameter.

    In the GET request sEcho=1 whereas in the POST request sEcho=0
    I have read something to do with sEcho=0 being for testing and therefore not displaying results.

    More research required...
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    if your server side code is looking at $_GET[] and you change $.ajax() to POST, change your server side code to use $_POST[]

    (a quick fix could be to merge the $_GET and $_POST arrays, add this to the top of your server_processing.php:
    [code]
    // http://php.net/manual/en/function.array-merge.php
    $_GET = array_merge($_GET, $_POST);
    [/code]
    )
  • steveocsteveoc Posts: 9Questions: 0Answers: 0
    Arghhhhhhh....

    Ok I found the problem.
    I'm using the Django SSP and realized that this is cast in GET.

    Solved.

    Hope this helps somebody.
  • steveocsteveoc Posts: 9Questions: 0Answers: 0
    @fbas Thanks for the pointers
This discussion has been closed.