By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 1,063 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

How can I return more than one value in an ajax

P: 1
I have 3 function in ajax and only 1 function returns a value. (playcal). why is this I know for sure the other function returns a function because I console.log them and it gives me an result.

HERE IS MY CODE

Expand|Select|Wrap|Line Numbers
  1. playerCal = function(confirmRows, pRatio){
  2.  
  3.     //Stores the player that makes the difference
  4.     var mep = [];
  5.     var w; 
  6.     var d; 
  7.     var l;
  8.  
  9.     (function($) {
  10.     //Connects to the json file
  11.     var url = 'http://beniky.co.uk/football/ars.json?callback=?';
  12.  
  13.     $.ajax({
  14.    type: 'GET',
  15.     url: url,
  16.     async: false,
  17.     jsonpCallback: 'jsonCallback',
  18.     contentType: "application/json",
  19.     dataType: 'jsonp',
  20.     success: function(data) {
  21.  
  22.                     //These 3 functions doesn't work
  23.            w = resultCount(data,'win');
  24.            d = resultCount(data, 'draw');
  25.            l = resultCount(data, 'lose');
  26.  
  27.            //Select the most commonly used players
  28.            //The amount of rows want to use, how many times they played in the last x games, return the player, the data to be read
  29.           forPlayerCal(confirmRows, pRatio, mep, data);
  30.  
  31.  
  32.     },
  33.     error: function(e) {
  34.        console.log(e.message);
  35.     }
  36. });
  37.  
  38. })(jQuery);
  39.  
  40.  
  41.      //return players played x amount of times, total w, d, l in data;
  42.      return [mep, w, d, l];
  43. }
May 19 '14 #1
Share this Question
Share on Google+
1 Reply


Dormilich
Expert Mod 5K+
P: 8,639
where is resultCount() defined?
May 19 '14 #2

Post your reply

Sign in to post your reply or Sign up for a free account.