Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my json data empty when using stringify to convert data?
    primarykey
    data
    text
    <p>When I use JSON.stringify, the data that is in it can't be send for some reason. But when I remove JSON.stringify, it does send and I would like to know why? Is there a way to controll the json data in PHP file without using stringify? Any help is much appreciated!</p> <pre><code>$(document).ready(function(){ $.ajax({ dataType: "jsonp", url: "***/server/jsonp/data", callback:"test", success: jsonSuccess }); function jsonSuccess( data ){ for( var i = 0; i &lt; data.length; i++ ){ if ( i == 0 ) { var formData = {name:"tolga",age:"25"}; // test object $.ajax({ type: "POST", url: "wp-content/themes/flex/saveJsonInfo.php", data: { info: JSON.stringify(data[i]) } }).done(function(data2) { console.log(data2); }); } } } }); </code></pre> <p>The json data that I receive is something like this:</p> <pre><code>test([{"EniNumber":"22325326","Name":"Test Fi","StartDate":"\/Date(1381788000000)\/","Rows":[{"T":42878,"Y":51.880965,"X":4.395925,"D":14.56},{"T":42879,"Y":51.880967,"X":4.395925,"D":14.56},{"T":42880,"Y":51.880967,"X":4.395925,"D":14.59}]}, {"EniNumber":"12312312","Name":"Test Fi 2","StartDate":"\/Date(13817880021300)\/","Rows":[{"T":42878,"Y":51.880965,"X":4.395925,"D":14.56},{"T":42879,"Y":51.880967,"X":4.395925,"D":14.56},{"T":42880,"Y":51.880967,"X":4.395925,"D":14.59}]}]) </code></pre> <p>This is how my PHP example file looks:</p> <pre><code>$json_data = $_POST['info']; if( isset($json_data) ){ echo json_encode( $json_data ); } else { echo json_encode( "What happened?" ); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload