【发布时间】:2017-03-05 13:54:09
【问题描述】:
大家好,我是 js/ajax 和 php 的初学者,如果你觉得我的问题很幼稚,我已经在我的配置文件中定义了站点 url,请提前抱歉
config.inc.php
$config['siteurl']= "http://".$_SERVER['SERVER_NAME']."/abc";
define('siteurl', $config['siteurl']);
现在在我的页面 em 上,包括配置文件,我检查了我正在问候 url 值,但我想要在 window.location.heref="" 这里打印我的函数中的值
$('#form_id').submit(function (e){
var $this = $(this);
e.preventDefault();
$.post($this.attr('action'), $this.serialize(), function (responseData) {
if(responseData == "success"){
window.location.href = <?php echo (siteurl) ?>;
}
else if (responseData){
swal({
title: "Error!",
text: responseData,
type: "error",
confirmButtonText: "ok"
});
}
});
});
如果我使用 window.location.href= "http://localhost/abc/abc.php";它工作正常
【问题讨论】:
-
这个
"/abc"和这个/abc.php"... 检查差异 AND 站点 url 是window.location.href = <?php echo (siteurl) ?>;
标签: javascript php jquery ajax