ajax ve php kullanıyorum ve ajax araması yaptığımda her dizimi eklemek istiyorum. Ama bu çalışmıyor.php array_push ajax çağrısından sonra diziye eklenmiyor
$('#multiple_upload_form' +count).ajaxForm({
target:'#images_preview'+count,
beforeSubmit:function(e){
console.log("gud to go");
},
success:function(data){
console.log(data);
console.log("succeded");
},
error:function(data){
console.log("failde");
}
}).submit();
PHP bu it.Plase PHP yan
<?php
$questionArr = array();
if($_POST['image_form_submit']){
array_push($questionArr,$questionNum);
if(is_array($questionArr)){
foreach($questionArr as $val) {
if ($val == $questionNum){
$response['response']= "exist";
echo json_encode($questionArr);
}else{
$response['response']= "question does not exist";
echo json_encode($response);
}
}
}else{
$response['response']= "not array";
echo json_encode($response);
}
}
?>
yardım edilir Ve bu benim HTML
<form method="post"name="multiple_upload_form"id="multiple_upload_form" enctype="multipart/form-data" action="php_work/test.php">
<input type="hidden" name="image_form_submit" value=""/>
<input type="file" name="images[]" id="images" multiple >
</form>
Php $ questionArr = array(); halinde ($ _ POST [ 'image_form_submit']) { \t \t \t array_push ($ questionArr, $ questionNum); \t \t halinde (is_array ($ questionArr)) { \t \t foreach ($ questionArr $ olarak val) { \t \t halinde ($ val == $ questionNum) { \t \t \t $ yanıtı [ 'yanıtı'] = "var"; \t \t \t echo json_encode ($ questionArr); \t \t} else { \t \t \t $ response ['response'] = "soru mevcut değil"; \t \t \t echo json_encode ($ response); \t \t} \t} \t \t \t} başka { \t \t $ yanıtı [ 'yanıtı'] = "değil dizi"; \t \t \t echo json_encode ($ response); \t} \t \t \t \t } ?> – trinidado
Bir yorum eklemek yerine bu kodu sorgunun içine düzenlemelisiniz :) – Jacob
'console.log()' çıktılarınızdan herhangi biri çalışır mı? ajax çağrısı bile gönderildi mi? formunuz aslında bir POST veya bir GET formu mu? –