Jump to content

How to fix jQuery XM parser problem?

- - - - -

  • Please log in to reply
No replies to this topic

#1
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
I want to use jQuery XML Parser do parse a link
function cofDoOrderBook() {
    var name = $('#name').val();
    var tel = $('#con').val();
    var degree = $('#class').val();
    var codeposti = $('#pc').val();
    var cityPrice = $('#city').val();
    var address = $('#add').val();
    var num = $('#num').val();
    var tprice = (num * ('29000' + cityPrice));
    var email = $('#email').val();
    $.ajax({
        type: "POST",
        url: "hpajax.php?do=orderBook",
        data: "name="+name+"&tel="+tel+"°ree="+degree+"&pcode="+codeposti+"&cityPrice="+cityPrice+"&address="+address+"&num="+num+"&tprice="+tprice+"&email="+email,
    }).done(function(data) {
        //alert(data);
        xmlDoc = $.parseXML(data);
        $xml = $(xmlDoc);
        $oid = $xml.find("oid");
        $trackcode = $xml.find("trackcode");
        $tprice = $xml.find("tprice");
        oid = $oid.text();
        trackcode = $trackcode.text();
        tprice = $tprice.text();
        alert(tprice);
    });
}
now I don't know my problem
also I test this code
function cofDoOrderBook() {
    var name = $('#name').val();
    var tel = $('#con').val();
    var degree = $('#class').val();
    var codeposti = $('#pc').val();
    var cityPrice = $('#city').val();
    var address = $('#add').val();
    var num = $('#num').val();
    var tprice = (num * (29000 + cityPrice));
    var email = $('#email').val();
    $.ajax({
        type: "POST",
        url: "hpajax.php?do=orderBook",
        data: "name="+name+"&tel="+tel+"°ree="+degree+"&pcode="+codeposti+"&cityPrice="+cityPrice+"&address="+address+"&num="+num+"&tprice="+tprice+"&email="+email,
        }).done(function(xmlData) {
            xmlDoc = $.parseXML(xmlData),
            $xml = $(xmlDoc),
            $s = $xml.find("s");
            $oid = $xml.find("oid");
            $trackcode = $xml.find("trackcode");
            $tprice = $xml.find("tprice");
            s = $s.text();
            oid = $oid.text();
            trackcode = $trackcode.text();
            tprice = $tprice.text();
            alert(tprice);
    });
}
Note:ajax function works fine!:bad:




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users