【发布时间】:2019-07-29 08:28:35
【问题描述】:
我正在尝试从 URL 动态加载 HTML。我使用此代码:
LoadingSpinner.open();
$.ajax({
url: '/Views/MyView',
data: data,
dataType: 'html',
type: 'GET',
success: function(response){
//This line trigger the error
$('#MyDiv').html(response.replaceAll('\n', ''));
LoadingSpinner.close();
},
error: function(){
LoadingSpinner.close();
ModalService.abrirModalError('Error de conexion', 'Ha ocurrido un error obteniendo la página');
}
});
当我确实单击一个元素时,我通过 GET MyView 请求,这工作正常,但是当我使用带有 $('#MyDiv').html(. ..) 该 HTML 中的脚本标记失败。包含我的脚本标签的 HTML 是这样的:
<script src="/NuevoERP/includes/js/gestion/productos/detailFamilia.js" type="text/javascript"></script>
<h2>Detalle de la familia {{$familia->desc_nombre}}</h2>
<div class="col-lg-12 m-t-5">
<div class="col-lg-3">
<label>Categoria de la familia: <span class="fontNormal">{{$familia->categoriaFamilia->desc_nombre}}</span></label>
<label>Referencia: <span class="fontNormal">{{$familia->code_referencia}}</span></label>
<label>Nombre: <span class="fontNormal">{{$familia->desc_nombre}}</span></label>
<?php if ($familia->familiaPadre != null) : ?>
<label>Familia padre: <span class="fontNormal">{{$familia->familiaPadre->desc_nombre}}</span></label>
<?php endif;?>
</div>
</div>
我正在尝试使用 src="/NuevoERP/includes/js/gestion/productos/detailFamilia.js" 包含 javascript 文件,但浏览器控制台显示正在尝试从“http://localhost:8080/NuevoERP/http://localhost:8080/NuevoERP/includes/js/gestion/productos/detailProductoServicio.js”加载文件,这是不正确的,正确的是“http://localhost:8080/NuevoERP/includes/js/gestion/productos/detailProductoServicio.js”
我正在使用带有 Lumen 框架的 Apache,我的应用程序位于我的 DocumentRoot 的其他路径中,我正在使用别名,这是我的 apache.conf:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:8080
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:8080>
DocumentRoot "/Volumes/HDD/NetBeansProjects/AntiguoERP/Desarrollo/ERP"
ServerName localhost
Alias /NuevoERP "/Volumes/HDD/NetBeansProjects/BaymaSalt/ERPBaymaSalt/public"
<Directory "/Volumes/HDD/NetBeansProjects/BaymaSalt/ERPBaymaSalt/public">
AllowOverride All
</Directory>
</VirtualHost>
我的 Lumen index.php("/Volumes/HDD/NetBeansProjects/BaymaSalt/ERPBaymaSalt/public") 的 .htaccess 是:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /NuevoERP/
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
我无法使用两个不同的 VirtualHost,我需要一个带有我的根路径 (http://localhost:8080) 和 php 5.0 的主机和我的 Alias /NuevoERP 和 php 7.0
【问题讨论】:
-
问题已编辑,谢谢 ;)
-
那么有两个问题吗?
$('#MyDiv').html(response.replaceAll('\n', ''));和http://localhost:8080/NuevoERP/http://localhost:8080/NuevoERP/? -
"这一行触发了错误"是什么错误?
标签: javascript jquery html apache lumen