v2.5.2
Giriş yap

ajax dosya yükleme + veri gönderme

burak001
755 defa görüntülendi
$.ajax({
    url:"pages/listele.php",
    data: new FormData(this),
    type:"POST",
    contentType: false,
    processData:false,
    cache:false,
    success:function(e){
     alert(e);
    }
});

ajax ile şöyle dosya yülemek için php dosyama veri gönderiyorum fakat bununla beraber ek olarak
html verisi nasıl gönderirim

html verim şöyle

var icerik = $(".rich_txt").html()
Cevap yaz
Cevaplar (6)
burak001
1147 gün önce

teşekkürler hallettim editör sıkıntılıydı onu kaldırdım beraber göndermiyor biri html() olarak aldığı için

trsherlock
1147 gün önce

Aşağıdaki kodları bir excel dosyasını php ile okutmak için kullanıyorum. Deneyebilir misin?

$('#excelFile').prop('files')[0] tam emin değilim ama çoklu göndereceksen sonundaki [0] kodunu kaldırman gerekebilir.

<input id="excelFile" type="file" />
$('#excelFile').change(function () {
    var file_data = $('#excelFile').prop('files')[0];
    var form_data = new FormData();
    form_data.append('excelFile', file_data);
    
    $.ajax({
        url: 'excel_to_html_table.php', // point to server-side PHP script 
        dataType: 'json',  // what to expect back from the PHP script, if anything
        cache: false,
        contentType: false,
        processData: false,
        data: form_data,
        type: 'post',
        
        success: function (dizi) {
        
        }
    });
})
burak001
1149 gün önce

buradaki hatayı yakaladım $('.rich_txt').html(); bu kodda sonunu html olarak
aldığım için type hatası veriyor bunu nasıl düzeltebilirim

burak001
1149 gün önce

olmadı hocam js tarafında şöyle bir hata veriyor
Cannot read property 'prompt' of undefined

at HTMLButtonElement.
tayfunerbilen
1150 gün önce

şöyle dener misin

var formData = new FormData(this);
formData.append('icerik', $(".rich_txt").html());
$.ajax({
    url:"pages/listele.php",
    data: formData,
    type:"POST",
    contentType: false,
    processData:false,
    cache:false,
    success:function(e){
     alert(e);
    }
});
haciyeff
1150 gün önce

String şeklinde gönderebilirsin. '$(".rich_txt").html()'