![](/img/trans.png)
[英]How To get Text Area Data (Html File in Text area) using ajax And i need to send data to Php ? Ajax not sending my Text area data?
[英]Converting a Text Area to a File (HTML JQuery AJAX PHP)
我有一个问题可能比我正在考虑的问题有另一个答案。
因此,我有一个由DB填充的文本区域。 我允许用户将其用作记事本等。
其中一些注释可能会变得很大,甚至可能超出URL字符限制。 我还必须编码(我正在使用encodeURIComponent)也切入字符数量的字符串。
我认为最好的方法是将文本区域转换为文件,然后将文件发布到我的处理程序php文件中,在该文件中将其上传到db中,什么都不会。 我不确定如何使用JQuery / Javascript来执行此操作,或者不确定是否可以使用另一种方法来执行此操作。
提前致谢!
-表格代码-
echo "<table class='content' id='quick-notes-list'>
<tr style='border-bottom:2pt solid #DFEFFC'>
<td colspan='2'>Note Name</td>
<td>Last Updated</td>
</tr>";
$i = 0;
while ( $Notes = mysql_fetch_array($getNotes) )
{
$style = ( $i % 2 ? 'ui-state-default row' : 'altrow row'); $i++;
$noteDate = date("M, d Y", strtotime($Notes['updated']));
$noteTime = date("g:i a", strtotime($Notes['updated']));
echo "
<tr class='noteName' onMouseOver=\"this.className='ui-widget-header row'\" onMouseOut=\"this.className='$style'\" >
<td valign='top'>
<a href='{$Notes['note_id']}'></a>
<b>{$Notes['note_name']}</b>
<br />
<i id='summary{$Notes['note_id']}'>" . substr($Notes['note_body'], 0, 150) . "...</i>
</td>
<td width='160' valign='top'>" . str_replace(" ", " ", $Contact['name']) . "</td>
<td width='120' valign='top'>
<i>" . str_replace(" ", " ", " {$noteDate} - {$noteTime}") . "</i>
</td>
</tr>
<tr id='note{$Notes['note_id']}' style='display: none' onMouseOver=\"this.className='ui-widget-header row'\" onMouseOut=\"this.className='$style'\">
<td colspan='2'>
<textarea id='note-body-{$Notes['note_id']}'>{$Notes['note_body']}</textarea>
</td>
<td style='text-align: right;'>
<button id='saveNote' value='{$Notes['note_id']}' class='ui-state-focus'>Save</button>
<button id='deleteNote' value='{$Notes['note_id']}' class='ui-state-focus'>Delete</button>
</td>
</tr>
";
}
-下面的AJAX功能-
$('#saveNote').click(function() {
noteID = $(this).attr('value');
newText = encodeURIComponent($('#note-body-' + noteID).val());
$.ajax({
url : "manage-save-quick-notes.php",
type : "POST",
data : data,
success: function(data, textStatus, jqXHR)
{
//data - response from server
},
error: function (jqXHR, textStatus, errorThrown)
{
}
});
要增加POST大小限制,请执行以下操作: 增加最大POST大小
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.