Php 头上的base标记使ajax无法工作

Php 头上的base标记使ajax无法工作,php,ajax,base,head,Php,Ajax,Base,Head,简而言之,我要说的是,我进行了一些调试,我发现头部的标记库使ajax无法工作。我有这个密码 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-

简而言之,我要说的是,我进行了一些调试,我发现头部的标记库使ajax无法工作。我有这个密码

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<base href="http://localhost/PaolaBoutique/">
<title>Untitled Document</title>
</head>

<body>

<?php
 include('fromincluded.php');
?>

<script type="text/javascript">


$(document).ready(function(e) {
    $("#testform").submit(function(e){
            e.preventDefault();
            $.post( "fromtest.php", $( "#testform" ).serialize() )
            .done(function(data) {
            document.getElementById("errormsg").innerHTML = data;       
            }); 

        });
});


</script>

</body>
</html>
fromsinclude.php

<form id="testform" method="post">
<input name="to" type="text" />
<input name="from" type="text" />
<textarea name="body" rows="10"></textarea>
<div id="errormsg"></div>
<input name="send" type="submit" value="send" />
</form>
最后从test.php的phpmailer中编写代码

<?php

//error_reporting(E_ALL);
error_reporting(E_STRICT);

date_default_timezone_set('America/Toronto');

require_once('../../PHPMailer_v5.1/class.phpmailer.php');
//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded

$mail             = new PHPMailer();

$body             = file_get_contents('contents.html');
$body             = eregi_replace("[\]",'',$body);

$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host       = "smtpout.secureserver.net"; // SMTP server
$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
$mail->SMTPAuth   = true;                  // enable SMTP authentication
$mail->Host       = "smtpout.secureserver.net"; // sets the SMTP server
$mail->Port       = 25;                    // set the SMTP port for the GMAIL server
$mail->Username   = "usr"; // SMTP account username
$mail->Password   = "password";        // SMTP account password

$mail->SetFrom($_POST["from"], 'First Last');

$mail->AddReplyTo($_POST["from"],"First Last");
$mail->AddAttachment("images/phpmailer.gif");      // attachment
$mail->Subject    = "PHPMailer Test Subject via smtp, basic with authentication";

$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test

$mail->MsgHTML($_POST["body"]);

$address = $_POST["to"];
$mail->AddAddress($address, "John Doe");

if(!$mail->Send()) {
  die( "Mailer Error: " . $mail->ErrorInfo);
} else {
  echo "Message sent!";
}

?>
当我从php主文件(ajax工作)中删除标记时,如果我犯了代码错误,任何人都有这方面的经验,并向我解释发生了什么


谢谢

是fromtest.php中的位置http://localhost/PaolaBoutique/fromtest.php? 另外,如果我没有弄错的话,请尝试将其移动到->之后的第1行,基本标记只影响html文档中的内容,例如html元素的属性,而不是javascript。您可以在javascript中使用绝对路径。也看到