我不明白爲什麼我的AJAX腳本會忽略所有折線。我首先鍵入文本到textarea然後點擊發送按鈕。這裏是我的AJAX實現:PHP:Ajax忽略文本中的折線
// creating ajax object
// ====================
function createRequestObject(){
try { return new XMLHttpRequest() }
catch(e)
{
try { return new ActiveXObject('Msxml2.XMLHTTP') }
catch(e)
{
try { return new ActiveXObject('Microsoft.XMLHTTP') }
catch(e) { return null; }
}
}
}
// message options (save, cancel)
// ==============================
function form1(text){
var http = createRequestObject();
if(http){
http.open("GET", "my_script.php?text=" + text);
http.onreadystatechange = function(){
if(http.readyState == 4){
alert("Ok!");
}
}
http.send(null);
} else {
document.location = "my_script.php?text=" + text;
}
}
HTML表單
<p align="justify" style="margin-right:10; margin-left:10;">
<table style="margin-right:10; margin-left:10;" align="center" border="0" cellpadding="0" cellspacing="0" width="680">
<TBODY>
<form name="fgform">
<tr>
<td width="680" height="100" colspan="2"><p><textarea id="edit_text1" name="edit_text" rows="3" style="width: 680; height: 100;"></textarea></p></td>
</tr>
<tr>
<td width="340"><p><input type="button" id="saveB" value="Save Text" style="color:rgb(0,204,0); background-color:white; border-width:1; border-color:rgb(225,218,202); border-style:solid; width:100;" onclick="form1(document.getElementById('edit_text1').value);"></p></td>
<td width="340"><p align="right"> </p></td>
</tr>
</form>
</TBODY>
</table>
任何其他解決這一建議的問題? – ilnur777 2010-04-06 15:57:40