thesnarkie Posted November 25, 2009 Report Posted November 25, 2009 $(document).ready(function() { $("#add_comment").submit(function(){ $("#submit_comment").hide(); $(".ajax_loading").show(); var str = $(this).serialize(); $.post("/p_gamma/news/index.php?action=comment", str, function(msg){ $("#ncomment_response").ajaxComplete(function(event, request, settings){ $("#submit_comment").show(); $(".ajax_loading").hide(); if(msg == "OK") { loadContents("#news_comments_r", "/p_gamma/news/index.php?action=read_comments&news_id=1"); } else { var login_response = msg; $("#ncomment_response").html(login_response); } }); }); return false; }); }); loadContents("#news_comments_r", "/p_gamma/news/index.php?action=read_comments&news_id=1"); Viņš atkārto viņu patstāvīgi. Kā, lai skriptam liek palaist to (loadContents) funkciju tikai vienreiz? Quote
indoom Posted November 25, 2009 Report Posted November 25, 2009 noņemot .ajaxComplete, kas domāts kā globālais ajax parametrs, kas palaižas katreiz, kad kāds ajax tiek pabeigts http://docs.jquery.com/Ajax/ajaxComplete Quote
thesnarkie Posted November 26, 2009 Author Report Posted November 26, 2009 Ok, sanāca, bet kā var no serializētajiem datiem paņemt kādu no tiem datiem, lai varētu izmantot tajā loadContents ? Nu, piemēram, serializētie dati ir glglg=445&sl=4455&fff=2345345. Tad kā es varu paņemt sl datus, lai izmantotu skriptā: loadContents("#news_comments_r", "/p_gamma/news/index.php?action=read_comments&news_id=1"); tā 1-ninieka vietā. Quote
indoom Posted November 26, 2009 Report Posted November 26, 2009 (edited) Ņem pa taisno no formas lauka vajadzīgo. Edited November 26, 2009 by indoom Quote
thesnarkie Posted November 26, 2009 Author Report Posted November 26, 2009 pateiksi kā? es vēl js/ajax/jquery ne īpaši orientējos, bet jāmācās ir. :) Quote
indoom Posted November 26, 2009 Report Posted November 26, 2009 ja pieņem, ka formas id = "add_comment", tad loadContents("#news_comments_r", "/p_gamma/news/index.php?action=read_comments&news_id=" + $("#add_comment input[name='sl']").val()); Quote
thesnarkie Posted November 26, 2009 Author Report Posted November 26, 2009 Liels paldies! ;) *piefiksē, kā tas darāms* Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.