The question is that I want to append a <script>
inside a div. If I use the following code it works fine:
$("<script />", {
"src":"http://en.parkopedia.co.uk/js/embeds/mapView.js",
"data-location":"http://en.parkopedia.co.uk/parking/" + src_fld,
"data-options":"l=0&tc=0&zc=1&country=UK&ts[]=4&ts[]=3&ts[]=2",
"data-size":"650:400",
"id":"script_map",
"type":"text/javascript"
}).appendTo("body")
but if I change body
for ("#divId")
it does not work. I tried using fiddle and works fine using a div id. Anyone know why does not work on my real page and works on fiddle?
http://jsfiddle.net/dperezq/oosttuc0/6/
The problem is that this map should be inside a div to appear only in one tab, because there are many tabs and I want to show it only in one of them. Are there any alternative to div instead body?
Update:
The error that show me when I change for #divId
is the following:
Uncaught Error: Missing attributes passed to mapView.js
And it goes to the following external .js:
if (
!script.hasAttribute('data-location')
|| !script.hasAttribute('data-options')
|| !script.hasAttribute('data-size')
) {
throw new Error('Missing attributes passed to mapView.js');
}
Showing the error "Missing attributes passed to mapView.js", but those attributes are not change only the appendTo() tag.
Update2: Libraries included in my project
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="http://code.jquery.com/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" integrity="sha512-K1qjQ+NcF2TYO/eI3M6v8EiNYZfA95pQumfvcVrTHtwQVDG+aHRqLi/ETn2uB+1JqwYqVG3LIvdm9lj6imS/pQ==" crossorigin="anonymous"></script>