我有这个Ajax代码来提交PHP表单.代码工作,但我希望<div>内容应该更改为刷新而不会刷新整个页面.
div的ID是#container.
这是AJAX代码:
$('.accept_friend').submit(function(){
var data = $(this).serialize();
$.ajax({
url: "../accept_friend.php",
type: "POST",
data: data,
success: function( data )
{
//here is the code I want to refresh the div(#container)
},
error: function(){
alert('ERROR');
}
});
return false;
});
Run Code Online (Sandbox Code Playgroud) 我有一些来自ajax调用的输出数据,我想取出数据的最后8个字符,但也要从字符串中删除它们,当我打印出数据时,我拍摄的字符串不会显示出来.
这是我尝试过的代码,它成功地获取了最后8个字符,但没有删除它们.
var data = "This is some data 12345678";
var comment_id = data.slice(-8);
jQuery.trim(comment_id);
$('#comments_'+comment_id).html(data);
Run Code Online (Sandbox Code Playgroud)