Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
Using ajax to display Content-Type image

I wrote a HTML page who calls thmbnail.ws to generate thumbnail for given URL (in this code it's a map from gmap), this is my code :

 $.ajax({
 	url: 'https://cors-anywhere.herokuapp.com/http://api.thumbnail.ws/api/API_KEY/thumbnail/get?url=http://maps.google.com/?q=36.82,10.17&width=800',
 	crossDomain: true,
 	headers: {'X-Requested-With': 'XMLHttpRequest'},
 	contentType: "image/jpeg",

 	success: function (data) {
 		console.log('Thumbnail Call OK');
 		console.log('Data Type : ' + typeof(data));
 		$('#map2').html('Image : <img src="data:image/jpeg;base64,' + data + '" />');
 	}
 });	

This is the execution result :

execution result

I thought the response is base64 encoded data, so i've tried to put data into an img tag (in div#map2) but no way : As you can see I have strange chars in the image area ! Debugger says result is image/jpeg, if I click on "Response" tab I have this : Reponse content

And when I clik "here" I have the good image : the final generated image

I can't figure out the right data type and how to display it in my page !

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!