Guest User

Untitled

a guest
Jul 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. var files = ['john.xml','doe.xml']
  2. var newResult, temp;
  3.  
  4. function loadMyXMLFiles(){
  5.  
  6. // > let's load file by file using jquery's ajax-call:
  7.  
  8. $.each(files, function(index,value) {
  9.  
  10. $.ajax({
  11.  
  12. url: value,
  13. cache: true,
  14. success: function(data){
  15.  
  16. // > check if temp is empty, append or fill
  17.  
  18. (temp) ? temp += (data) : temp = data;
  19.  
  20.  
  21. // > on complete:
  22.  
  23. if (index == files.length-1) {
  24.  
  25. xmlResult = temp; temp = null;
  26. }
  27. }
  28.  
  29. });
  30. });
  31. }
  32.  
  33. loadMyXMLFiles()
  34.  
  35. var files = ['john.xml','doe.xml']
  36. var xmlResult, temp = ""; //Make temp an empty string
  37.  
  38. loadMyXMLFiles(){
  39. $.each(files, function(index,value) {
  40. $.ajax({
  41. url: value,
  42. cache: true,
  43. async: false, //This is crucial!
  44. success: function(data){
  45. temp += data;
  46. if (index == files.length-1) {
  47. xmlResult = temp; temp = null;
  48. }
  49. }
  50. });
  51. });
  52. }
Add Comment
Please, Sign In to add comment