Reputation: 52952
I want to do:
<script src='bob.js'></script>
But using a html file, ie.
<script type='html' src='bob.html'></script>
The html file contains multiple JQuery templates, so it will have to parse the html file for tags.
The src will be dynamic. I suspect the solution is JQuery, however I want it to be synchronous, just like with the first example.
How can I achieve this? I don't want to use another plugin, just native JQuery.
Upvotes: 1
Views: 2668
Reputation: 2008
you can get access to it using ajax:
function getPageObj(urlPath){
var response = $.ajax({
type: "GET",
dataType:'html',
async:false,
cache:true,
url: urlPath
}).responseText;
if(response==null ||response.length<1){return null;}
var obj = $(response);
return obj;
}
Upvotes: 3