jQuery AJAX POSTs to action both hit the same callback method instead of their own -



jQuery AJAX POSTs to action both hit the same callback method instead of their own -

an interesting problem have run into. have struts 2 web app utilize jquery ajax calls within jquery ui dialogs lookup data. same page has couple different dialogs looking different data. each dialog has paging, hence "next" links shown below. if have 1 dialog or multiple dialogs calling same callback works fine. have multiple dialogs, each calling own callback action class breaks (meaning getcustsearchhtml() method gets called in both ajax calls below). when click on next link during task-lookup, right action method gets called success callback calls returndata.custsearchhtml instead of taskdata.tasksearchhtml. here basic code:

$('#customer-lookup').delegate('#clnextlink', 'click', function(e) { e.preventdefault(); var workorderid = $("#workorderid").val(); var nextpage = $("#nextpage").val(); $.ajax({ type: "post", url: "customerlookup", data: { id: workorderid, page: nextpage }, datatype: "json", success: function(returndata) { $("#customer-lookup").html(returndata.custsearchhtml); } }); }); $('#task-lookup').delegate('#tlnextlink', 'click', function(e) { var workorderid = $("#workorderid").val(); var nextpage = $("#nextpage").val(); $.ajax({ type: "post", url: "tasklookup", data: { id: workorderid, page: nextpage }, datatype: "json", success: function(taskdata) { $("#task-lookup").html(taskdata.tasksearchhtml); } }); homecoming false; }); ...... <div id="customer-lookup" class="ui-dialog" title="customer lookup"> ..... <a id="clnextlink" href="#">next page</a> ..... </div> <div id="task-lookup" class="ui-dialog" title="task lookup"> ..... <a id="tlnextlink" href="#">next page</a> ..... </div>

anyone ever see before or know might doing wrong? thanks!

you have multiple elements same id in html. invalid , mess jquery in sorts of ways.

edit:

you still using class selector .tlnextlink tlnextlink id

jquery ajax callback

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -