神秘的换行符被追加到阿贾克斯加载内容 [英] Mysterious line break is being appended to ajax loaded content
问题描述
无论是使用阿贾克斯还是.load,我加载从一个.html页面内容进入或替换元素。在这两种情况下,内容被调用,插入,有一个神秘的新线(不休息的元素,而是像一个\ n或\ r)的从.html文件我的内容后面。
在Chrome的元素检查,它看起来像:
< DIV CLASS =加载父>
//我所有的加载内容
< / DIV>
(鬼线)
有在code没有休息,所以我不知道在哪里,这是来自哪里。
html的:
< DIV ID =ForgotPasswordForm级=AJAX>
< H2>重置您的密码测试< / H>
< DIV CLASS =BlockContent>
&其中p为H.;在下面输入您的电子邮件,要求密码重置。一封邮件将会发送一个重置链接。 &所述; / P>
&其中,P类=的ErrorMessage的风格=显示:无>< / P>
<形式的行动=/?的login.php行动= send_password_email方法=邮报的onsubmit =返回check_forgot_password_form()>
< DIV>
< DL样式=宽度:270px;保证金:0汽车;高度:30PX;>
< DT风格=浮动:左;宽度:100像素;文本对齐:右;保证金:5px的5px的0 0;> <跨度类=必需> *< / SPAN>电子邮件地址:< / DT>
< DD风格=浮动:左;字体大小:12px的;宽度:150像素;>
<输入类型=填充:4PX;类型=文本级=文本框NAME =电子邮件ID =电子邮件/>
< / DD>
< / DL>
&其中,P类=提交的风格=文本对齐:中心>
<输入类型=提交值=继续/>
&所述; / P>
< / DIV>
< /形式GT;
< / DIV>
< / DIV>
脚本:
$('#恢复通)。点击(
功能(E){
即preventDefault();
//$('#login-content').load('/content/ResetPassword.html');
$阿贾克斯({
网址:/content/ResetPassword.html,
成功:功能(数据){
$('#登录内容)replaceWith(数据)。
('进行加载。')警告;
}
});
});
大多数文本文件格式保存在EOF最后的换行字符的文件。假设你处理这个HTML文件就像服务器端包含,这可能导致你的症状。
Using either .ajax or .load, I'm loading content from an .html page into or replace an element. In either case, the content is called and inserted and there is a mysterious new line (not a break element , but like a \n or \r) appended after my content from the .html file.
In chrome's element inspector it looks like:
<div class="loaded parent">
// all my loaded content
</div>
"
(ghost line)
"
There are no breaks in the code so I have no idea where this is coming from.
.html:
<div id="ForgotPasswordForm" class="ajax">
<h2>Reset Your Password test</h2>
<div class="BlockContent">
<p> Enter your email below to request a password reset. An email will be send with a reset link. </p>
<p class="ErrorMessage" style="display:none"></p>
<form action="/login.php?action=send_password_email" method="post" onsubmit="return check_forgot_password_form()">
<div>
<dl style="width: 270px;margin: 0 auto;height: 30px;">
<dt style="float: left;width: 100px;text-align: right;margin:5px 5px 0 0;"> <span class="Required">*</span> Email Address: </dt>
<dd style="float:left;font-size:12px;width:150px;">
<input style="padding:4px;" type="text" class="Textbox" name="email" id="email" />
</dd>
</dl>
<p class="Submit" style="text-align:center">
<input type="submit" value="Continue" />
</p>
</div>
</form>
</div>
</div>
Script:
$('#recover-pass').click(
function(e){
e.preventDefault();
//$('#login-content').load('/content/ResetPassword.html');
$.ajax({
url: '/content/ResetPassword.html',
success: function(data) {
$('#login-content').replaceWith(data);
alert('Load was performed.');
}
});
});
Most text file formats save the file with a final line break character at EOF. Assuming you're treating this html file like a server side include, that's probably causing your symptoms.
这篇关于神秘的换行符被追加到阿贾克斯加载内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!