How to solve a problem with base tag?

狂风中的少年 提交于 2019-12-04 04:00:52

问题


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?


回答1:


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", ...)


来源:https://stackoverflow.com/questions/3211142/how-to-solve-a-problem-with-base-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!