使用ajax和jquery发送div id
如何使用相同的脚本发送我的div的id! 就像用户发送表单一样,我也想发送de div的id。 我想为我的图片上传系统制作评论系统使用ajax和jquery发送div id,jquery,html,send,Jquery,Html,Send,如何使用相同的脚本发送我的div的id! 就像用户发送表单一样,我也想发送de div的id。 我想为我的图片上传系统制作评论系统 $(function() { $(".submit").click(function() { var name = $("#name").val(); var email = $("#email").val(); var comment = $("#comment").val(); var da
$(function() {
$(".submit").click(function() {
var name = $("#name").val();
var email = $("#email").val();
var comment = $("#comment").val();
var dataString = 'name='+ name + '&email=' + email + '&comment=' + comment;
if( comment=='')
{
alert('Please Give Valide Details');
}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle"> <span class="loading">Loading Comment...</span>');
$.ajax({
type: "POST",
url: "piccommentajax.php?id=<? echo $idcom ?>",
data: dataString,
cache: false,
success: function(html){
$("ol#show").append(html);
$("ol#show li:first").fadeIn("slow");
document.getElementById('comment').value='';
$("#name").focus();
$("#flash").hide();
}
});
}
return false;
});
});
$(函数(){
$(“.submit”)。单击(函数(){
var name=$(“#name”).val();
var email=$(“#email”).val();
var comment=$(“#comment”).val();
var dataString='name='+name+'&email='+email+'&comment='+comment;
如果(注释=“”)
{
警报(“请提供Valide详细信息”);
}
其他的
{
$(“#flash”).show();
$(“#flash”).fadeIn(400.html('loadingcomment…');
$.ajax({
类型:“POST”,
url:“piccommentajax.php?id=”,
数据:dataString,
cache:false,
成功:函数(html){
$(“ol#show”).append(html);
美元(“ol#show li:first”)。法登(“slow”);
document.getElementById('comment')。值=“”;
$(“#名称”).focus();
$(“#flash”).hide();
}
});
}
返回false;
});
});
这是在给定代码的情况下要做的:
datastring += '&divid=' + $('...').attr("id");
您为…
输入的内容会产生很大的不同。我们无法从这个问题中知道
不过,随便猜一猜?Try:
$(this).closest(“div”).attr(“id”)代码>这将获得与单击的提交按钮最近的封闭div。div的id是什么意思?您是在谈论div的html id还是什么?您可以使用$(div).attr('id')
获取div id。是的,像这样的内容为什么随机非jQuery调用document.getElementById('comment')。value='
为什么不$('#comment')。val('')
?我的意思是我想发送我的