How enable in php long query strings

This test code:

<script>
   $(document).ready(function() {
   var dataString = {c0: 0, c1: 1, c2: 0, c3: 0, c4: 0};
   $.ajax({
      url: 'http://localhost/sitepoint/showvars.php',
      type: 'POST',
      data: dataString,
}).done(function ( data, status, xhr ) {
   // do something with the result
   console.log(data);
}

works for me, I get the various c0, c1 and so on as $_POST['c0'], $_POST['c1'] and more.

This

  contentType: "html",

isn’t correct, better to leave it as the default value to allow your PHP to know that your are sending form data.

3 Likes

contentType: “html”,// must be the ERROR

checked LAST SCRIPT success

soon implement it

Thank you

$arr = json_decode($_POST["data"], true);

http://localhost/repos/CodeIgniter-3.1.9_BestOfficeDeskSetup_com_live/public_html/SudokuSolver/index.html

make it POST request LOCALHOST WORKING FULLY BUT LIVE>>>> ERROR // IS IT PHP 7 OR PHP PROBLEM ON SERVER OR … IS CODEIGNITER INSTALLATION ERROR IN PARENT FOLDER?

jquery.js:8706 POST http://www.bestofficedesksetup.com/SudokuSolver/ajax-processor.php **500 (Internal Server Error)**


http://www.bestofficedesksetup.com/SudokuSolver/index.html

http://www.bestofficedesksetup.com/SudokuSolver/ajax-processor.php 

So are you still having problems? Post the code and someone will try to help.

LOCALHOST IS OK BUT live error see attachments — is it .htaccess or codeigniter in parent folder install ???

<?php

ini_set('display_errors', '1');         
ini_set("max_execution_time",35 ); //you can use this if you know your script should not take longer than 15 seconds to finish
register_shutdown_function('shutdown');

//var_dump(json_decode($_POST["data"]));
//echo ($_GET["c00"]);
//die();


define("N", 9);
define("UNASSIGNED", 0);

$grid = [];


$arr = json_decode($_POST["data"], true);  // true for getting array Not obj

for($i=0; $i<9; $i++) :
    
    for($j=0; $j<9; $j++) :
        $grid[$i][$j] = $arr["c".$i."".$j];
    endfor;

endfor;

Your screenshot indicates a reference error on line 27.

Your code block only has 26 lines.

One of these things doesn’t match.

Show us the JavaScript that you use to call the PHP code. The error message is complaining that it can’t find an array member called 'data' in an array somewhere.

Note that in my sample code above for calling the PHP code, my variables arrived in $_POST['c0'], $_POST['c1'] and so on, there was no need to call JSONDecode to get them out.

ETA - Oh, I see it now, I didn’t use JSON.stringify above, just passed the array in and it was automatically dealt with.

again … localhost post and sudoku working fully ok

provided half php code
the the urls // IF WORKED THESE ARE NOT SUPPORTED GETTING THE SAME OUTPUT??? BUT NOT SEE SHOTS / PICTURES — NOT NEEDED ALL CODE HENCE LOCALHOST WORKING BUT LIVE NOT… MUST BE ERROR WITH PHP ON SERVER OR .HTACCESS OR PARENT FOLDER… CODEIGNITER INSTALLATION…

http://localhost/repos/CodeIgniter-3.1.9_BestOfficeDeskSetup_com_live/public_html/SudokuSolver/ajax-processor.php

http://www.bestofficedesksetup.com/SudokuSolver/ajax-processor.php 500 

fixed and live by updated php56 to php70

thank you

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.