本主题与其他“ajax to php”主题不同,我在这里使用xml类型的php文件,我想通过ajax将一些数据发送到这个php文件,但是php没有从ajax中检索任何数据。当我删除标题函数时,它从ajax获取数据。这是我的jQuery-ajax代码;
var borcu_son = $('#borcu').val();
var borclu = $('#borclu').val();
if(borcu_son > 0){
$.ajax({
url : 'borc_takip_xml.php',
data : {'borcu_son':borcu_son,'borclu':borclu},
type: 'post',
success: function(){
alert('send successfull!');
},
error: function(){
alert('ajax failed!');
}
});
}
和php文件;
<?php
header('Content-Type: text/xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8" ?>';
echo '<xml>';
?>
<?php ////////////////// BORÇ OLUŞTUĞUNDA BİLGİLERİ AJAXLA AL //////////////////
if(isset($_POST['borclu']) && isset($_POST['borcu_son'])){
$borclu = $_POST['borclu'];
$olusan_borc = $_POST['borcu_son'];
$borclu_childs = '';
$borclu_childs .= '<borclu>';
$borclu_childs .= '<isim>'.$borclu.'</isim>';
$borclu_childs .= '<tutar>'.$olusan_borc.'</tutar>';
$borclu_childs .= '</borclu>';
echo $borclu_childs;
};
echo '</xml>';
?>