refresh javascript using require
<body>
<p id="contents">Nothing loaded.</p>
<button id="reload">Reload</button>
<script>
require.config({ // require's configuration
baseUrl: "./js",
paths: {
jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min', // file path
}
});
require(["jquery"], function ($) {
var $contents = $("#contents");
function reload() {
require.undef("text!../file.html"); // "clear" the required code
require(["text!../file.html"], function (file) { // re-require the code
$contents.empty(); // your optional code (can be omitted) by just using:
$contents.append(file); // require(["text!../file.html"]);
});
}
$("#reload").click(reload); // call the refresh function in a button or another function
});
</script>
</body>
Also in JavaScript:
- javascript date countdown
- ERROR in ./src/app/pages/auth/auth.module.ngfactory.js Module not found: Error: Can't resolve '@angular/material/core/index'
- classList has class
- express post request body undefined
- React hooks update parent state from child
- c# parse json
- how to reload page on button click in javascript
- render react in blaze
- js new array from new set
- react redux
- bash parse json
- command to create react app
- spreadjs autofit column with minimum
- what is adapter.js
- chart.js label word wrap
- what is amqp10 policy nodejs
- discord js fetch user
- display none in jquery
- vue js cdn
- kill all node processes
- react image upload component
- Prevent Multiple Form Submissions With JQuery
- best js method
- node.js