こんにちは論理思想家!!、PHP で記述された関数呼び出しから返された配列から JSON オブジェクトを返そうとしています。昨日オブジェクトを返していましたが、どういうわけか私はそれを壊すことができました。どなたか助けていただければ幸いです。以下は、私のJavascriptとPHPからリストされたコードです...提供される可能性のあるヘルプに感謝します。
--PHP--
<?php
class FileSel{
public $event;
public $posUsr;
public $posPass;
public $posAddr;
public $scUsr;
public $scPass;
public $scAddr;
public $cclUsr;
public $cclPass;
public $confName;
//Variable used to hold the connection
var $scp;
//Variable used to hold the final list of files to be displayed to the user to choose from
var $List = array();
//Variable used to hold the list of possible SC files
var $SCFiles = array();
//Variable used to hold the list of possible POS files
var $POSFiles = array();
//Variable used to hold the list of possible CCL files
var $CCLFiles = array();
function __construct(){
$this->debug = new debug();
}
public function execute(){
$this->debug->putLog("Made it to FileSel->execute()\n");
return new Response(true, "Build List executed", json_encode($this->buildList()));
}
public function load_post_data(){
$this->debug->putLog("Made it to FileSel->load_post_data()\n");
$this->event = $_POST['event'];
$this->posUsr = $_POST['pos_user'];
$this->posPass = $_POST['pos_password'];
$this->posAddr = $_POST['pos_address'];
$this->scUsr = $_POST['sc_user'];
$this->scAddr = $_POST['sc_address'];
$this->cclUsr = $_POST['ccl_user'];
$this->cclPass = $_POST['ccl_password'];
$this->confName = $_POST['confName'];
if( strlen($this->event) <= 0) return false;
if( strlen($this->posAddr) <= 0) return false;
if( strlen($this->posUsr) <= 0) return false;
if( strlen($this->posPass) <= 0) return false;
if( strlen($this->scAddr) <= 0) return false;
if( strlen($this->scUsr) <= 0) return false;
if( strlen($this->scPass) <= 0) return false;
if( strlen($this->cclUsr) <= 0) return false;
if( strlen($this->cclPass) <= 0) return false;
if( strlen($this->confName) <= 0) return false;
return true;
}
public function buildList(){
$this->debug->putLog("Made it to FileSel->buildFileArray()\n");
//Build a list of files from the POS
$this->listPOSFiles();
//Build a list of files from the SC
$this->listSCFiles();
//Build a list of files from the CCL
$this->listCCLFiles();
$this->debug->putLog("Building final file list\n");
//Variable used to keep track of index of final list
$j=0;
//Here we are adding POS files to the final list
foreach($this->POSFiles as $file){
$this->List[$j] = $file;
$this->debug->putLog("Added POS File: $file to final file list\n");
$j++;
}
//Here we are adding POS files to the final list
foreach($this->SCFiles as $file){
$this->List[$j] = $file;
$this->debug->putLog("Added SC File: $file to final file list\n");
$j++;
}
//Here we are adding POS files to the final list
foreach($this->CCLFiles as $file){
$this->List[$j] = $file;
$this->debug->putLog("Added CCL File: $file to final file list\n");
$j++;
}
return $this->List;
}
}
?>
--Javascript--
function displayDialog(){
//console.log("Made it to displayDialog");
var fileData = {
"event" : "createFileSelectDialog",
"pos_address" : file_pos_address,
"confName" : file_confName,
"pos_user" : file_pos_user,
"pos_password": file_pos_password,
"ccl_user" : file_ccl_user,
"ccl_password": file_ccl_password,
"sc_address" : file_sc_address,
"sc_user" : file_sc_user,
"sc_password": file_sc_password
};
$.ajax({
url: './lib/app.php',
data: fileData,
type: 'POST',
dataType : 'json',
success: function(data){
console.log(data);
alert("Data Loaded: " + data);
},
complete: function(data) {
console.log(data);
}
});
}
この問題の解決に役立つその他の情報がありましたら、お知らせください。投稿させていただきます。