0
$(".resource_body_build_stone_ok").click(function(){
    $.post("ajax.php",
    {
      build:"resource",
      id: $(this).attr('data-id-build'), 
      level:$(this).attr('data-level-build')
    },
    function(data,status){
        $(".resource_body").load("resource_b.php/?r=1");
        $(".frame_stock").load("stock.php");
        alert("Data: " + data + "\nStatus: " + status);
    });
});

If the value id: $(this).attr('data-id-build') is 1 to 10 , how can I set id value in resource_b.php/?r=1 instead the value 1.

For example, if value of $(this).attr('data-id-build')=5 ==> resource_b.php/?r=5

TlonXP
  • 3,325
  • 3
  • 26
  • 35
naser
  • 171
  • 2
  • 13

3 Answers3

2
$(".resource_body_build_stone_ok").click(function(){
    var id = $(this).attr('data-id-build');
    $.post("ajax.php",
    {
      build:"resource",
      id: $(this).attr('data-id-build'), 
      level:$(this).attr('data-level-build')
    },
    function(data,status){
        $(".resource_body").load("resource_b.php/?r=" + id);
        $(".frame_stock").load("stock.php");
        alert("Data: " + data + "\nStatus: " + status);
    });
 });
Furquan Khan
  • 1,586
  • 1
  • 15
  • 30
1
<script>
$(".resource_body_build_stone_ok").click(function(){
    var dID = $(this).attr('data-id-build'); //use this dID where you want use dynamic id
    $.post("ajax.php",
    {
      build:"resource",
      id: dID, 
      level:$(this).attr('data-level-build')
    },
    function(data,status){
        $(".resource_body").load("resource_b.php/?r=" + dID);
        $(".frame_stock").load("stock.php");
        alert("Data: " + data + "\nStatus: " + status);
    });
});
</script>
Kuldeep Raj
  • 791
  • 1
  • 7
  • 29
1

Please check the example http://jsfiddle.net/2dJAN/85/

var id_build = $(this).attr('data-id-build')

 $(".resource_body").load("resource_b.php/?r="+id_build);

For reference I alert the url format in example.

vinothini
  • 2,606
  • 4
  • 27
  • 42