我正在尝试使用ajaxForm函数发送包含在表单中的数据。它在localhost中工作正常,但是当我在互联网上试用它时它不起作用并显示错误。
这是我的表单标题
<form id="form" role="form" action="controller/PagesManager.php" enctype="multipart/form-data" method="post">
这是ajaxForm JS文件的包含
<script src="assets/js/jquery.form.js"></script>
这是我的AJAX功能
function saveBonReception(){
$('#form').ajaxForm({
success: function(responseText, statusText) {
if($.trim(responseText) == 'ok'){
$(location).attr('href', 'index.php?p=BonReception&msg=true');
}
},
error : function(b, msgError) {
alert("Error Ajax : " + msgError);
}
}).submit();
}
这是我在PagesManager.php中的嗜好
if(!empty($_FILES['docFour'])){
$brcPath = '../BRC_Files/';
$brcFile = $_FILES['docFour']['name'];
list($txt, $ext) = explode(".", $brcFile);
$nameFile = 'File_'.time().'.'.$ext;
$tmp = $_FILES['docFour']['tmp_name'];
$fileUploaded = move_uploaded_file($tmp, $brcPath.$nameFile);
if(!$fileUploaded) die('notOk');
}
else {
$nameFile = 'Aucun Fichier';
}
$bonReceptionEntity = new BonReceptionEntity();
$bonReceptionManager = new BonReceptionManager();
$bonReceptionEntity->setmagasinier(($_SESSION ['ADMIN_ID']));
$bonReceptionEntity->setcode($_POST['codeBonReception']);
$bonReceptionEntity->setdate(dateformat_jQueryUI_to_SQL($_POST['dateBrc']));
$bonReceptionEntity->setdate_doc_four(dateformat_jQueryUI_to_SQL($_POST['dateDocFour']));
$bonReceptionEntity->setfournisseur($_POST['fournisseur']);
$bonReceptionEntity->setcode_doc_four($_POST['codeDocFour']);
$bonReceptionEntity->settype_doc_four($_POST['typeDocFour']);
$bonReceptionEntity->setdoc_four($nameFile);
$bonReceptionEntity->setTOT_REMISE_L($_POST['TOT_REMISE_L']);
$bonReceptionEntity->setPR_REM_P($_POST['PR_REM_P']);
$bonReceptionEntity->setMT_REM_P($_POST['MT_REM_P']);
$bonReceptionEntity->setTOT_HT_BRUT($_POST['TOT_HT_BRUT']);
$bonReceptionEntity->setTOT_HT_NET3($_POST['TOT_HT_NET3']);
$bonReceptionEntity->setTOT_HT_NET1($_POST['TOT_HT_NET1']);
$bonReceptionEntity->setTOT_FODEC($_POST['TOT_FODEC']);
$bonReceptionEntity->setTOT_HT_NET2($_POST['TOT_HT_NET2']);
$bonReceptionEntity->setTOT_TVA($_POST['TOT_TVA']);
$bonReceptionEntity->setD_TIMBRE($_POST['D_TIMBRE']);
$bonReceptionEntity->setTOT_TTC($_POST['TOT_TTC']);
$bonReceptionEntity->setetat($_POST['etat']);
$bonReceptionEntity->setdescription('This is description');
$lignesIdArt = array();
$lignesCodeArt = array();
$lignesDesArt = array();
$lignesQteArt = array();
$lignesPuhtArt = array();
$lignesTvaArt = array();
$lignesDpaArt = array();
$puhtArtLigne = array();
$qteLigne = array();
$remiseLigne = array();
$thtLigne = array();
$tvaLigne = array();
$fodecLigne = array();
$ttcLigne = array();
if(isset($_POST['idArt'])) $lignesIdArt = $_POST['idArt'];
if(isset($_POST['codeArt'])) $lignesCodeArt = $_POST['codeArt'];
if(isset($_POST['desArt'])) $lignesDesArt = $_POST['desArt'];
if(isset($_POST['qteArt'])) $lignesQteArt = $_POST['qteArt'];
if(isset($_POST['puhtArt'])) $lignesPuhtArt = $_POST['puhtArt'];
if(isset($_POST['tvaArt'])) $lignesTvaArt = $_POST['tvaArt'];
if(isset($_POST['dpaArt'])) $lignesDpaArt = $_POST['dpaArt'];
if(isset($_POST['puhtLigne'])) $puhtArtLigne = $_POST['puhtLigne'];
if(isset($_POST['qteLigne'])) $qteLigne = $_POST['qteLigne'];
if(isset($_POST['remiseLigne'])) $remiseLigne = $_POST['remiseLigne'];
if(isset($_POST['thtLigne'])) $thtLigne = $_POST['thtLigne'];
if(isset($_POST['tvaLigne'])) $tvaLigne = $_POST['tvaLigne'];
if(isset($_POST['idTvaLigne'])) $idTvaLigne = $_POST['idTvaLigne'];
if(isset($_POST['fodecLigne'])) $fodecLigne = $_POST['fodecLigne'];
if(isset($_POST['ttcLigne'])) $ttcLigne = $_POST['ttcLigne'];
echo $bonReceptionManager->addNewBonReception(
$bonReceptionEntity, $lignesIdArt, $lignesCodeArt, $lignesDesArt, $lignesQteArt, $lignesPuhtArt, $lignesTvaArt,
$puhtArtLigne, $qteLigne, $remiseLigne, $thtLigne, $tvaLigne, $fodecLigne, $ttcLigne, $lignesDpaArt );