PHP: Ajax ignores line foldings in the text
Posted
by ilnur777
on Stack Overflow
See other posts from Stack Overflow
or by ilnur777
Published on 2010-04-06T15:20:19Z
Indexed on
2010/04/06
15:23 UTC
Read the original article
Hit count: 246
I don't understand why my AJAX script ignores all line foldings. I first type text to the textarea and then put onclick to send button. Here is my AJAX realization:
// 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 form
<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>
© Stack Overflow or respective owner