English 中文(简体)
我将如何更新j Query,以便让 mu子点击,用ja子活叫/更新数据?
原标题:How would I update jQuery to allow mutiple button clicks to dynamically call/update data using ajax?

hey guys, im having some trouble... i m able to capture the first button on the page, but there are a total of 10 buttons. When I click on any of those 10 buttons, only the first button s value is called and the other ones don t update. is there a way to capture all of the buttons so they each have their own independent value and update their values so jQuery s ajax function gets the new one? the buttons are being created out of a multidimensional array loop.

<?php
$characters = $char->getCharactersListFromAccountId($_SESSION[ acctid ]);
 foreach ($characters as $key) {
  if(is_array($key)){
    echo "<input class="button" type="button" href="javascript:void(0)" value="Show" style="vertical-align: top" />";
    echo $char->getFaction($key[ guid ]), "&nbsp;";
    echo $char->getClass($key[ guid ]), "&nbsp;";
    echo "<span class= style >", $char->getLevel($key[ guid ]), "</span>&nbsp;";
    echo "<span class= style >", $key[ name ], "</span>";
    echo "<input class="GUID" type="hidden" name="GUID" value="";
    echo $key[ name ];
    echo "" />";
    echo "<br>";
  } else {
    echo "<br>";
    echo "<b><h1>My Characters: $key</h1></b><br />
";
  }
}
?>
<div id="view" style="display: none;"></div>
<script>
 $(".button").livequery( click , function(event) {
  var GUID = $( .GUID ).val();
  $("#view").html( Retrieving... );
  $("#view").show("slow");
  $.ajax({
   type: "POST",
   data: "ID=" + GUID,
   url: "character.php",
   success: function(msg){
    $("#view").html(msg);
   }
  });
});
</script>
问题回答

从我可以收集的角度来看,你面临的问题是,你只需要寄送属于被点击的纽顿的GUID,即该文件中的下一个。 如果我正确的话,你可以尝试:

$(".button").livequery( click , function(event) {
    // get the next GUID value
    var GUID = $(this).nextAll( .GUID:first ).val();
    ...

此外,是否真的需要为此使用生活频率?





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签