如何解决与基地标签的问题? [英] How to solve a problem with base tag?

查看:78
本文介绍了如何解决与基地标签的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有基地标签的问题。它看起来像
<基地的HREF =htt​​p://myexamplepage.com/myfolder//>

一切正常,除了这个查询:
$。获得(应用程序/软/ calendar_month_change.php,...)

我的电脑认为它是跨域服务器和改变查询选项....当我删除了基本标记,它工作正常,但我的网站不显示任何图像。我使用Smarty的模板引擎。我该如何解决呢?

解决方案
  

我该如何解决呢?

希望我的意见吗?不要使用基础。正是由于这个原因presented这里:它造成混乱,并影响该系统的其他部分的方式,是非常困难的调试。 (虽然我不知道它甚至影响相对AJAX调用。)

我会定义一个Web根目录在Smarty的,和prePEND,对于文档中的每个图像的URL。更改Web根依然轻松,但浏览器被赋予绝对URL。

您可以,但是,也解决了这个由Ajax请求提供了一个绝对的URL,并留下了基础到位。

  $。获得(http://domain.com/application/soft/calendar_month_change.php,...)
 

I have a problem with base tag. It looks like
<base href="http://myexamplepage.com/myfolder/" />.

Everything works, besides this query:
$.get("application/soft/calendar_month_change.php", ...)

My computer thinks it's cross domain server and changes query to OPTIONS .... When I remove the base tag, it works correctly but my site doesn't show any images. I use smarty template engine. How can I solve it?

解决方案

How can I solve it?

Want my opinion? Don't use base. Exactly for the reason presented here: It creates confusion, and influences other parts of the system in a way that is extremely difficult to debug. (Although I didn't know it even influences relative AJAX calls.)

I would define a web root in Smarty, and prepend that for every image URL in the document. Changing the web root remains easy, but the browser is given absolute URLs.

You could, however, also solve this by providing an absolute URL in the Ajax request and leave the base in place.

$.get("http://domain.com/application/soft/calendar_month_change.php", ...)

这篇关于如何解决与基地标签的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆