First of all i have the following to convert my Javascript array to a JSON array.
<script type="text/javascript" src="https://github.com/douglascrockford/JSON-js/blob/master/json2.js"></script>
var sv_defaultArray = new Array([]);
sv_defaultArray[0] = "post 4";
sv_defaultArray[1] = "post 5";
sv_defaultArray[2] = "post 6";
var myJsonString = JSON.stringify(sv_defaultArray);
Now i would like to write the converted array to a json file lets say http://www.foobar.com/array.json via any conventional method possible.
So now i am at the following stage with php and jQuery.post facilities;
<?php
$list = $_POST["array"];
$fp = fopen('array.json', 'w');
fwrite($fp, $list);
fclose($fp);
?>
$.post("http://www.foobar.com/write.php", { 'array': myJsonString});
The above solution is giving me errors mainly returned in console as origin errors.
json-padding
seems appropriate. – jAndy Aug 24 '11 at 9:01