![](/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.