1

When the user press entre the data will be save into database.

Ajax

    $('td.edit').keydown(function(event){


    arr = $(this).attr('class').split( " " );
     var clientid=document.getElementById("client").value;
     account_id=document.getElementById("account_id").value;


     if(event.which == 13)
     { 

$.ajax({    type: "POST",
                        url:"clientnetworkpricelist/update.php",
                        data: "value="+$('.ajax input').val()+"&rowid="+arr[2]+"&field="+arr[1]+"&clientid="+clientid+"&account_id="+account_id,
                        success: function(data){

                        $('#CPH_GridView1_Status').append(data);
                        $('.ajax').html($('.ajax input').val());
                        $('.ajax').removeClass('ajax');
                                                }});
                                 }

                              }

Html

<td  id="CPH_GridView1_Status'.$rows['net_id'].'" class="edit2 status '.$rows["net_id"].' "><img  src="image/'.$rows["status"].'f.png" /></td>

After success I want to retrieve data from database and place it in the proper td ( in the same row of the clicked td) i am success to retrieve data but not retrieve in the correct td

3
  • Use the context: option to $.ajax() to send context to the success function that identifies the row. Commented Nov 28, 2013 at 7:18
  • You have just to display it in the resulted page of your AJAX call and take it from the data sent back by your AJAX call. Commented Nov 28, 2013 at 7:19
  • $(this) pointer should be still pointing to the clicked td, so why dont you use that to set the data back on to the event generated td Commented Nov 28, 2013 at 7:19

2 Answers 2

2

which row you want to load data? change it:

$('#CPH_GridView1_Status').append(data);

to

$('#CPH_GridView1_Status'+arr[2]).append(data);
Sign up to request clarification or add additional context in comments.

3 Comments

thank you for your answer it worked but if i add again it showing more than one data it not clearing the previous data can you tell me how to clear the previous data when new data is addes
use html instead of append: $('#CPH_GridView1_Status'+arr[2]).html(data);
please see this question stackoverflow.com/questions/20262515/… and please provide me you suggestion thanks
1

Before appending data first clear current '' using

$('#CPH_GridView1_Status'+arr[2]).empty();

and then append data

$('#CPH_GridView1_Status'+arr[2]).append(data);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.