我在项目中使用AJAX时遇到困难。
我的ejs文件中有一个Date输入字段,在如下所示的onchange事件中,我在其中调用外部函数(在单独的JS文件中),
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"environmentName": {
"type": "string"
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"entropy": "[uniqueString(resourceGroup().id, parameters('environmentName'))]",
"vnetName": "[concat(parameters('environmentName'), 'vnet')]",
"vnetPrefix": "10.0.0.0/8",
"subnetName": "WebAppSubnet",
"subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('vnetName'), variables('subnetName'))]",
"subnetPrefix": "10.0.0.0/24",
"appServicePlanName": "[concat(parameters('environmentName'), 'asp')]",
"webAppName": "[concat(parameters('environmentName'), variables('entropy'))]"
},
"resources": [
{
"apiVersion": "2018-04-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('vnetName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('vnetPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]",
"serviceEndpoints": [
{
"service": "Microsoft.Storage"
}
],
"delegations": [
{
"name": "webapp",
"properties": {
"serviceName": "Microsoft.Web/serverFarms",
"actions": [
"Microsoft.Network/virtualNetworks/subnets/action"
]
}
}
]
}
}
]
}
},
{
"apiVersion": "2017-08-01",
"type": "Microsoft.Web/serverfarms",
"kind": "app",
"name": "[variables('appServicePlanName')]",
"location": "[parameters('location')]",
"properties": {},
"dependsOn": [],
"sku": {
"name": "S1"
}
},
{
"apiVersion": "2016-08-01",
"type": "Microsoft.Web/sites",
"kind": "app",
"name": "[variables('webAppName')]",
"location": "[parameters('location')]",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
},
"resources": [
{
"name": "virtualNetwork",
"type": "config",
"apiVersion": "2018-02-01",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('Microsoft.Web/sites/', variables('WebAppName'))]",
"[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'))]"
],
"properties":
{
"subnetResourceId": "[variables('subnetRef')]",
"swiftSupported": true
}
}
],
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
]
}
]
}
我正在将2个参数传递给上述函数,
onchange =“ confDateChange('<%= ConferenceRoom.id%>','<%= conferenceRoom.name%>')”
在外部JS文件中,功能如下:
<input id="confbookdate" type="date" onchange="confDateChange('<%= conferenceRoom.id %>', '<%=conferenceRoom.name %>')" required></input>
调用GET Route(在app.js文件中)并且结果进入数据时,我正在从MongoDB中获取一些数据记录。
现在我需要在我的ejs文件中使用此数据。需要检查一些条件并将结果显示在我的ejs文件中。
如何将结果数据从外部js文件传递到ejs文件?
我无法为此找到任何解决方案:-(