jQuery ajax request to php, how to return plain text only

Posted by jyoseph on Stack Overflow See other posts from Stack Overflow or by jyoseph
Published on 2010-12-30T00:24:48Z Indexed on 2010/12/30 0:54 UTC
Read the original article Hit count: 238

Filed under:
|
|
|

I am making an ajax request to a php page and I cannot for the life of me get it to just return plain text.

    $.ajax({
       type: 'GET',
       url: '/shipping/test.php',
       cache: false,
       dataType: 'text',
       data: myData,   
       success: function(data){
        console.log(data)
       }   
     });

in test.php I am including this script to get UPS rates. I am then calling the function with $rate = ups($dest_zip,$service,$weight,$length,$width,$height);

I am doing echo $rate; at the bottom of test.php. When viewed in a browser shows the rate, that's great. But when I request the page via ajax I get a bunch of XML. Pastie here: http://pastie.org/1416142

My question is, how do I get it so I can just return the plain text string from the ajax call, where the result data will be a number?

Edit, here's what I see in Firebug- Response tab:

alt text

HTML tab:

alt text

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery