Mitgard Mitgard

Mitgard Mitgard

  • NA
  • 21
  • 2.4k

How do I get svg in an ajax request in Angular 2?

Jul 18 2018 10:39 PM
Hi, can you help me? What I need is to get an svg file through an ajax request using angular 2 I have it in jquery but I would get it using the HttpClient method
Is this possible?
 
current code 
  1. get_svg_elm = function (url) {  
  2.   
  3.     var elm = "";  
  4.     $.ajax({  
  5.         url: "assets/img/data_svg/" + url,  
  6.         data: "",  
  7.         async: false,  
  8.         dataType: "xml",  
  9.         success: function (svg) {  
  10.             elm = svg.documentElement.innerHTML;  
  11.   
  12.         }  
  13.     });  
  14.     return elm;  
  15. }  
 this function returns the path tag of the svg

Answers (1)