简体   繁体   English

在需要时如何包括文件?

[英]How include files just when need them?

I am using Laravel, sending Ajax requests to server. 我正在使用Laravel,将Ajax请求发送到服务器。 But I don't need some libraries like DropzoneJS (a library for Ajax uploading ), some images, some functions before some Ajax requests. 但是在某些Ajax请求之前,我不需要像DropzoneJS (一个用于Ajax上传的库)之类的库,一些图像,一些功能。

Is there any way to include them after some actions? 经过一些动作后有什么方法可以包含它们吗?
for example include a library when an element clicked 例如,当元素单击时包括一个库

Is there any library to do this job? 有图书馆可以做这项工作吗?

If you need to pre-load required stuff you can use requirejs for that purpose. 如果您需要预加载必需的内容,可以为此使用requirejs
Keep in mind that using it will "hold" your code until all the requirements are for-filled. 请记住,使用它会“保留”您的代码,直到满足所有要求为止。

If you need to do some stuff after the AJAX is completed you can use promises or callbacks to capture the response and do what ever you need to do. 如果您需要在AJAX完成后做一些事情,则可以使用Promise或回调来捕获响应并执行所需的操作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何包含外部JS文件而不将它们包含在head标签中? - How to include external JS files without including them in the head tag? 当我只单击其中一个问题时,我需要帮助禁用其他问题的下拉样式 - I need HELP in disabling dropdown styles for other questions when I click on just one of them 如果在页面中包含2个版本的jQuery,如何将插件限制为其中一个? - If you include 2 version of jQuery in a page how do you restrict a plugin to just one of them? 引导警报:如何在关闭时“隐藏”它们而不删除它们? - Bootstrap alert : how to just 'hide' them without removing them when closing? 如何将组件存储在数组中并在需要时在 React 中渲染它们? - How to store components in an array and render them when I need in React? 在Orchard cms我想要包含某些.js文件,我应该把它们放在哪里以及如何将它包含在我的项目中? - In Orchard cms I want to include certain .js files, where should i put them and how should i include it in my project? 如何使用 Drupal 在另一个页面中调用我的 CSS 或 JavaScript 文件并将它们包含在多个页面中 - How do I use Drupal to call my CSS or JavaScript files in another page and include them in multiple pages 如何包含我的JavaScript文件而不单独列出所有文件? - How can include my javascript files without listing them all individually? 在Visual Studio中使用打字稿时,为什么需要在default.htm中包含多个.js文件? - Why do I need to include multiple .js files in default.htm when working with typescript in visual studio? 如何通过JQuery和JQueryUI获得我所需的东西(即:我不想导入它们) - how to get just what I need by JQuery and JQueryUI (i.e.: I don't want to import them)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM