동일한 페이지에 두 개의 양식 제출. 두 가지 양식과 필드가 있으며 ID와 이름이 다릅니다. 두 형식 중 하나가 잘 작동하지만 두 번째 문제가 있습니다 잘못된 항목이 있으면 정상적으로 오류 메시지를 받아야하며 모든 내용이 정상이면 배열 데이터가 필요합니다. 양식 2 단계에서 메시지를 코딩해야합니다. 다른 형식의 데이터 검색
내 PHP 코드 :는
//To get errors messages normally
if(!empty($errors2)) {
$data != "noPassed";
echo display_errors2($errors2);
}
else {
//To retrieve data I need to code my message in step 2
$data2 = array();
$data2['client_id'] = $client_id;
$data2['client_civilite'] = $client_civilite;
$data2['client_name'] = $client_name;
$data2['res2'] = "passed";
header('Content-Type: application/json');
echo json_encode($data2);
}
스크립트 : g에
jQuery.ajax({
url : '/myfolder/parsers/check.php',
method : 'POST',
type : 'POST',
data : data,
success : function(data){
//I presume errors in followed condition
if (data != 'passed') {
jQuery('.messages_erreurs').html(data);
}
if(data2.res2 == 'passed') {
$(".frm").hide("fast");
$("#step2").show("slow");
$(".open1").css("display","none");
$(".open2").css("display","inline-block");
// accès à data.client_civilite, data.client_id, pour message d'identification .
$('#clt_id').val(data2.client_id);
$("#check_ok").html(data2.client_civilite+" "+data2.client_nom+" "+': identification réussie.');
}
기능 등의 오류 메시지를 텍스트, HTML 또는 JSON을 :
function display_errors2($errors2) {
$display2 = '<ul class="bg-danger">';
foreach ($errors2 as $error2){
$display2 .= '<li class="text-danger">'.$error2.'</li>';
}
$display2 .= '</ul>';
return $display2;
}
메시지 오류 데이터를 기반으로 ... (나는 아래의 코드를 추가). 나는 2 단계에서 3e 데이터를 검색하기 위해 제이슨 에코와 res2를 만들었습니다. – juliet
혼란 스러웠습니다 : 그것은 단지 잘못된 배치 포옹이었습니다 .... – juliet