我有一个包含 AJAX 功能的模块,我希望导出到我的客户端控制器,但我得到的模块未定义,我使用的是 NodeJS 和 Cloud9 环境。
AJAX 模块
module.exports = {
appUrl: window.location.origin,
ready: function(fn) {
if(typeof fn !== 'function') {
return;
}
if(document.readyState === 'complete') {
return fn();
}
document.addEventListener('DOMContentLoaded', fn, false);
},
ajaxRequest: function(method, url, callback) {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if(xmlhttp.readyState === 4 && xmlhttp.status === 200) {
callback(xmlhttp.response);
}
};
xmlhttp.open(method, url, true);
xmlhttp.send();
}
};
Run Code Online (Sandbox Code Playgroud)
客户端控制器
'use strict';
var ajaxFunctions = require("../common/ajax-functions.js");
(function(){
var profileId = document.querySelector('#profile-id') || null; …Run Code Online (Sandbox Code Playgroud) 什么时候应该在创建超类时使用Java中的Public over Protected,如果程序在没有任何问题的情况下运行受保护的访问修饰符集,是否需要将其更改为Public?