我正在尝试从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",中,但浏览器控制台显示正在尝试从“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 Framework的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和我的别名/NuevoERP与php 7.0
发布于 2019-03-21 16:42:56
代码是正确的,问题是一个合作伙伴创建了一个AJAX请求拦截器,并在运行时修改了URL,什么也没说就创建了它,这就是修改web浏览器的请求以获取javascript文件
https://stackoverflow.com/questions/55044021
复制相似问题