我正在尝试从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()在“ MyDiv”中使用jQuery将此视图呈现到我的页面时。 ..)HTML内的script标签失败。包含我的脚本标签的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>
我正在尝试将javascript文件添加到src =“ / NuevoERP / includes / js / gestion / productos / detailFamilia.js”,但浏览器控制台显示了我正在尝试从“ {{3} }”,那是不正确的,正确的是“ http://localhost:8080/NuevoERP/http://localhost:8080/NuevoERP/includes/js/gestion/productos/detailProductoServicio.js”
我将Apache与Lumen Framework一起使用,我的应用程序位于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>
我的流明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/NuevoERP/includes/js/gestion/productos/detailProductoServicio.js)在php 5.0中使用,我的Alias / NuevoERP在php 7.0中
答案 0 :(得分:0)
代码是正确的,问题是合作伙伴创建了一个AJAX请求拦截器并在运行时修改了URL,创建时没有说什么,这是在修改Web浏览器的请求以获取javascript文件>