Ciao a tutti,
ho un problema con una semplice funzione, vorrei passare un dato da una funzione javascript ad un file php, cosi ho implementato queste funzioni:
PHP
codice:
<?php
$data = $_POST['data'];
echo json_encode($data);
?>
JAVASCRIPT
codice:
$(window).load(function(){
        $('#export').click(function() {
			$.ajax({
				type: "POST",
				url: "creaFile.php",
				data: "francesco",
				success: function(response){
					window.alert(response);
				//	window.location.href = response.url;
				}
			})
		});
	});
il problema è che appena faccio partire la funzione il response è nullo, questo ovviamente porta ad avere internal error 500 appena cerco di fare una funzione piu complessa che può essere questa:
codice:
<?php

$data = $_POST['data']; // get the data from the AJAX call - it's the "data: grid.getData()" line from above

/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');

if (PHP_SAPI == 'cli')
	die('This example should only be run from a Web Browser');

/** Include PHPExcel */
require_once 'Classes/PHPExcel.php';

$countryArray = array($data,'USA','GERMANY','FRANCE','BELGIUM','SWEDEN','JAPAN','CHILE','BOTSWANA','SRI LANKA');

$objPHPExcel = new PHPExcel();
$objPHPExcel->removeSheetByIndex(0);

foreach($countryArray as $ck =>$cv) {
    $sheet = $objPHPExcel->createSheet($ck);
    $sheet->setTitle($cv);
    $sheet->setCellValue('A1', $cv.' '.$ck);
}

$objPHPExcel->setActiveSheetIndex(0);

$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('CountrySheets.xls');

$response = array(
    'success' => true,
    'url' => 'CountrySheets.xls'
);

header('Content-type: application/json');

// and in the end you respond back to javascript the file location
echo json_encode($response);

?>
sapete darmi una mano?