可能重复:
如何使用jQuery设置/取消设置cookie?
来人帮帮我.如何使用jQuery创建,读取和删除一些cookie?
我使用jQuery和TinyMCE提交表单,但序列化中存在一个问题,即Textarea值没有发布.
这是代码:
<form id="myForm" method="post" action="post.php">
<textarea name="question_text" id="question_text" style="width:543px;height:250px;"></textarea>
</form>
Run Code Online (Sandbox Code Playgroud)
语言:lang-js
$('#myForm').submit(function() {
$.ajax({
type: 'POST',
url: $(this).attr('action'),
data: $(this).serialize(),
success: function(data) {
$('#result').fadeIn('slow');
$('#result').html(data);
$('.loading').hide();
}
})
return false;
});
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,separator,image,separator,justifyleft,justifycenter,justifyright,jformatselect,fontselect,fontsizeselect,justifyfull,bullist,numlist,undo,redo,styleprops,cite,link,unlink,media,advhr,code,preview",
theme_advanced_buttons2 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resize_horizontal : false,
theme_advanced_resizing : true,
extended_valid_elements :"a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
});
Run Code Online (Sandbox Code Playgroud)
你能解释一下我应该改变什么,以及为什么要发布文本区域的价值?
首先,为了显示cookie,我使用了来自electrictoolbox.com的代码.
然后我做了一个表格来添加一些cookie:
<form class="cokies" method="post">
<input class="query" name="q" type="text" />
<input type="submit" name="save" value="saving">
<a>Delete Cookies</a>
</form>
Run Code Online (Sandbox Code Playgroud)
$(document).ready(function(){
$('.cokies a').click(function(){
$.cookie('q', null);
});
remember('[name=q]');
Run Code Online (Sandbox Code Playgroud)
此功能来自komodomedia.com:
function remember( selector ){
$(selector).each(function(){
//if this item has been cookied, restore it
var name = $(this).attr('name');
if( $.cookie( name ) ){
$(this).val( $.cookie(name) );
}
//assign a change function to the item to cookie it
$(this).change(function(){
$.cookie(name, $(this).val(), { path: '/', expires: 365 });
});
});
}
Run Code Online (Sandbox Code Playgroud)
问题是,我无法弄清楚如何删除cookie.
我想从给定的URL中删除"&start = 2".这是我试过的:
$uri = "http://test.com/test/?q=Marketing&start=2";
$newuri = str_replace("&start=","",$url);
echo $newuri;
Run Code Online (Sandbox Code Playgroud)