html - send div id with ajax and jquery -
how send id of div same script! when user sends form, want send id of de div too. want create commentsystem pictures uploadssystem.
$(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(); } }); } homecoming false; }); });
this given code:
datastring += '&divid=' + $('...').attr("id");
what set in ...
makes difference. there's no way know question.
taking wild guess, though? try: $(this).closest("div").attr("id");
closest enclosing div clicked submit button.
jquery html send
No comments:
Post a Comment