Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 25th, 2012  |  syntax: None  |  size: 1.17 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Setting variable from within AJAX call?
  2. int[] array = {1,2,4,5,3,5,3,5};
  3.  
  4.     response.setContentType("application/json");
  5.     response.setCharacterEncoding("UTF-8");
  6.     response.getWriter().write(new Gson().toJson(array));
  7.        
  8. var test2 = [];
  9.     $.post("servlet", { info: data},
  10.                 function(data) {
  11.                     alert(data); // this alerts what i want stored...
  12.                     test2.push(3); // testing if i can add 3 to test FAILS
  13.                 });
  14.     test2.push(9); //this works
  15.     test2.push(9); //this works
  16.     options.series[0].data = test2;
  17.        
  18. var test2 = [];
  19. $.post("servlet", { info: data},
  20.             function(data) {
  21.                 alert(data); // this alerts what i want stored...
  22.                 test2.push(3); // testing if i can add 3 to test FAILS
  23.                 alert(test2)
  24.             });
  25.        
  26. function(data){
  27.     options.series[0].data=data;
  28. }
  29.        
  30. var test2 = [];
  31. $.ajax({
  32.    url: "servlet",
  33.    async: false,
  34.    type: "post",
  35.    data: { info: data},
  36.    success: function(data) {
  37.                 alert(data); // this alerts what i want stored...
  38.                 test2.push(3); // testing if i can add 3 to test FAILS
  39.             });
  40. });