0

This topic is diffrent from other "ajax to php" topics, im here using xml type php file and I want to send some data to this php file via ajax, but php is not retrieving any data from ajax. when i remove header function it gets data from ajax. here is my jQuery-ajax code;

        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!');
                }
            });
        }

And php file;

<?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>';
?>
Tamer Durgun
  • 401
  • 3
  • 9
  • try setting `dataType:'xml'` – charlietfl Aug 09 '15 at 20:17
  • With the little information you've provided I closed it against the reference question on how to make an AJAX request to php. Feel free to add additional information in which way your question is different to the existing material of that topic we have on site already and provide references to the existing material. – hakre Aug 09 '15 at 20:32
  • did try "dataType:xml" bu it didn't worked. – Tamer Durgun Aug 09 '15 at 21:20
  • need to inspect the actual request in browser dev tools network and see what problem is – charlietfl Aug 09 '15 at 23:20

0 Answers0