php - Dynamic Row Only Added on First Click -
i have application seems work pretty except 1 small glitch can't seem figure out. hoping here.
i have table can dynamically add rows to. there 2 ways add rows, checkbox loads pre-determined data, or image, adds blank row table.
the checkbox works great, image link works first time, , not next.
this image line:
<img src="img/plus.png" width="25" height="25" id="btnaddrow" title="add new row" class="idfirst alternativerow" />
alternativerow generated code here: http://www.examplet.buss.hk/jquery/table.addrow.php (example #10, more complex) , line this:
$(".alternativerow").btnaddrow({oddrowcss:"oddrow",evenrowcss:"evenrow"});
the "idfirst" block of jquery code this:
$(document).ready(function(){ $(".idfirst").click(function(){ result = 0; id = 0; jquery.ajax({ url: 'getitemid.php?q=<?php echo $q; ?>', success: function(result) { id = result; if(result.isok == false) alert(result.message); }, async: false }); window.location.href='page.php?q=<?php echo $q; ?>&id=<?php echo $id; ?>'; }); });
i reload because want new number created in getitemid.php dynamically load. important because added link created within new row. code in getitemid follows:
$q = $_get['q']; $description = $_get['description']; $rate = $_get['rate']; $hours = $_get['hours']; $query = "insert items (q, description, hours, rate) values ('".$q."','".$description."','".$hours."','".$rate."')"; $results = mysql_query($query) or die(mysql_error()); $nextid = mysql_insert_id(); echo $nextid;
so problem when click image link first time, works great, , blank row, links in dynamic row work properly, life good.
but moment press second time, page reload, don't new row. return existing rows before refresh.
i wondering if can see i'm doing wrong , offer advice. (yes, understand of maybe not ideal way make work, part working way need to...and i've spent tons of hours make these moving parts along).
thank in advance advice.
i did manage figure out.
i testing out in ie, users using. same issue in firefox, use.
i came across article http://www.electrictoolbox.com/jquery-json-ajax-caching/ , once tried in chrome, turned out browser issue. implemented following solutions:
i added
$.ajaxsetup({ cache:false });
to top of script, , measure, added
cache: false,
to ajax call.
now works great everywhere.
Comments
Post a Comment