Re: jQuery Ajax won't return data

99 views
Skip to first unread message

asgallant

unread,
Nov 26, 2012, 2:07:36 PM11/26/12
to google-visua...@googlegroups.com
I'm not quite sure what is going on here, as I've never used callbacks with async set to false.  It should work if you use this:

var result = $.ajax({
type:"get",
dataType:"text",
async:false,
error: function(result){
alert("There is no data to populate the map.");
}
}).responseText;

Alternatively, you could make it asynchronous and put the rest of your code into the success callback and see if that works.

If you direct the ajax query to a non-existent URL, does the error code run?

On Monday, November 26, 2012 10:52:12 AM UTC-5, Michael Ofori-Appiah wrote:
I ma trying to get data using jqery.ajax from a servlet but it is not returning data.  However, when I run the servlet url in the browser, it displays the data.
The code is as shown below:  Both the success and error does not return anything.  Can anybody please assist.

function drawChart() {
       var result=null;
       $.ajax({
   type:"get",
   dataType:"text",
   async:false,
   success:function(data){
   result= data; 
   },
   error: function(result){
   alert("There is no data to populate the map.");
   }
   });
Reply all
Reply to author
Forward
0 new messages