I cant think in how i can do this some help please.
I get some json objects and one of the values has html tags, some images, of course i cant fetch the images because they have relative urls, and the site it is host in a sub-domain.
Is there any way to add the http://example.com/ to the already existing images/image.png
thanks
this is my json response:
description": "<img src=\"images/stories/Icons/Vacuum.png\" mce_src=\"images/stories/Icons/Vacuum.png\" border=\"0\" alt=\"Vacuum\" title=\"Vacuum\"> <img src=\"images/stories/Icons/Washing_Machine.png\" mce_src=\"images/stories/Icons/Washing_Machine.png\" border=\"0\" alt=\"Washing Machine\" title=\"Washing Machine\"></p>"
for(var i = 0; i < objJsonA.length; i++){
var ap = objJsonA[i];
var lot = ap.lot;
$('.myclass').html(lot);
}
this returns 404 errors, the content i’m fetching it is on http://www.mysite.com and i am on m.mysite.com
You can use
document.locationto get the current server. For example, on the URL for this server in Chrome console I see:So you could use:
There are a lot of plugins for working with URLs in JavaScript/jQuery and it probably makes sense to use one of them (example search).