Solution 1 :

It depends on the path. If it’s a local path (eg. file://C:/foo.txt) then no, you cannot do this for security reasons.

If it’s a relative path to a public resource held on your own server (eg. /folder/file.html) then yes, this is possible. In your case you would just need to fix your syntax to create a valid function and provide the argument to load():

jQuery($ => {
  loadContent('/path-to-your/file.html');
});

function loadContent(path) {
  $('#content').load(path);
}

Problem :

I want to pass some files path into a JavaScript or Jquery function, so this can display those files (HTML files) into a div when clicking an a tag.

its possible?

something like this:

  <script>
    $(document).ready(function loadcontent(pathfile){
      $('#content').load("pathfile");
    });
  </script>

The div:

<div id="content">
  HTML FILE HERE
</div>

Comments

Comment posted by Keith

Browser’s Javascript does not have direct access to files, no.

Comment posted by jose alexander pascual rosa

@Keith the files are hosted on a server, not even like that?

Comment posted by Keith

@josealexanderpascualrosa You maybe need to update your question ->

By