【发布时间】:2013-04-29 08:20:02
【问题描述】:
我使用这个 jquery-ajax 脚本来发送电子邮件:
$.ajax({
url: process.php,
type: "POST",
data: data,
cache: false,
...
在url我调用了发送邮件的php文件,但是ajax只有在我指定完整路径的情况下才能得到:
url: "http://www.domain.com/wp-content/themes/site_theme/templates/process.php",
但我必须使用这样的语法:
url: "../../templates/process.php",
或者使用变量在html页眉/页脚中声明
HTML
<script type="text/javascript">
var urlMail = '<?php bloginfo('template_url'); ?>/templates/process.php';
</script>
脚本
url: "../../templates/process.php",
但是对于上述两种情况,浏览器控制台都会检索到这个错误:
POST http://www.domain.com/templates/process.php 404 Not Found 1.56s
我哪里错了?
【问题讨论】:
-
你试过了吗:
url: "templates/process.php",? -
指定完整路径有什么问题?
-
@jtheman:使用您的解决方案,它会检索到此错误
POST http://www.domain.com/contact-page/templates/form-contatti-mail.php 404 Not Found 1.34s -
@Musa:因为我会在其他项目中使用这个脚本,不想每次都更新路径。
-
<?php bloginfo('template_url'); ?>实际回显了什么???如果这是您的错误,则看起来是空的:POST http://www.domain.com/templates/process.php 404 Not Found 1.56s
标签: php ajax wordpress variables filepath