2

Code:

function getEcoScore(geometry, dataType){
     return $.ajax({
        type:'POST',
        data: {geometry:geometry,
            attType:dataType},
            dataType:'text',
            url: 'php/eco_query.php'
        });

      }
function test(){
      var x = getEcoScore(geoJsongeom,"wetlands").done();
      console.log(x.responseText);
     }

I want to store the result of this request and run a few other requests on different tables, then process the results into an HTML format to form a pop up/dialog box. When I run this code with just console.log(x), I get and object with the responseText, however, then I try to access the responseText it comes up as undefined.

I have tried processing the response in done(function(data){...code...}); but still all i get is an object for x. Is there a particular function for accessing the responseText?

I have used a callback function to assign the response to a global variable & that remains undefined.

The main issue is why I cannot access the responseText variable of the response.

user3277403
  • 137
  • 4
  • Also http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call?rq=1 – Musa Dec 30 '14 at 02:21
  • As I said, I tried using the .done(function(data){code}) which is the callback function? I also tried declaring a global variable and having a callback function assign the processed response to the global. The global remains undefined still. – user3277403 Dec 30 '14 at 02:26

0 Answers0