[英]Converting a Text Area to a File (HTML JQuery AJAX PHP)
I have a question that might have another answer than what I'm thinking of doing. 我有一个问题可能比我正在考虑的问题有另一个答案。
So, I have a text area that is populated by a DB. 因此,我有一个由DB填充的文本区域。 I'm allowing the users use it as a notepad and whatnot.
我允许用户将其用作记事本等。
Some of these notes can get pretty big and potentially exceed the URL Character limit. 其中一些注释可能会变得很大,甚至可能超出URL字符限制。 I also have to encode (I'm using encodeURIComponent ) the strings which cuts into the amount of characters too.
我还必须编码(我正在使用encodeURIComponent)也切入字符数量的字符串。
I thought the best way would be to convert the text area into a file and then post the file towards my handler php file where it gets uploaded into the db and whatnot. 我认为最好的方法是将文本区域转换为文件,然后将文件发布到我的处理程序php文件中,在该文件中将其上传到db中,什么都不会。 I'm not certain how to do this with JQuery/Javascript or if there was another way to handle this.
我不确定如何使用JQuery / Javascript来执行此操作,或者不确定是否可以使用另一种方法来执行此操作。
Thanks in advance! 提前致谢!
-- Table Code -- -表格代码-
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 Function Below -- -下面的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)
{
}
});
To increase the limit POST size limit: Increasing the maximum post size 要增加POST大小限制,请执行以下操作: 增加最大POST大小
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.