Loading a static HTML from public folder with jQuery

I am using a jquery plugin that is loading a static HTML file from a local URL. So I put the HTML file in the public folder and pass the URL to the $.post. The URL is correct, when I access the URL directly in the browser it shows the HTML content, but via jQuery post it seems to load a Meteor site.

Does anyone know how to load a static HTML with jQuery from the public folder?

Can you show us how you are doing it right now. What does your code look like?

Loading inside React Component:

componentDidMount() {

  $.post(Meteor.absoluteUrl('test.html'), function(data) {
  	console.log(data);
  });

}

In the console I see its loaded, but the data contains:

and not the actual HTML from the HTML file. I think its a problem with routing. When the ajax call is made, it seems to load the 404 page. But when I access the URL directly via browser, its showing the HTML content.

Have you tried using a GET request instead of POST? I’m not sure how Meteor behaves with POST requests to the public folder.

1 Like

Great thats working. Do you know why its not working with POST.

Probably because a POST request is usually used to make the server “do” something for you. Save data in a database for example.

The public folder is only supposed to serve files. If you need to use POST, PUT or some other request you will have to use a server side router, like Picker.

But in your case I guess you only want to GET the content of your file.