0

I have a dropdown box, and when it changed, i will display a table containing information in the database using JQuery. Now that one is working good. In the same time, I want to apply the "edit in place" to that table. When I clicked a row, then I am able to change the value of the row,however, the data is not change when I submit the new value. I have to refresh my page and then the value will be updated. I suspect it is because of the table which is called using JQuery. But here is the codes. I am using this function to display the table of information:

function loadData(page){
    var dataString = "";
    dataString = "page="+page;
    $.ajax({
        type: "POST",
        url: "load_data.php",
        data: dataString,
        success: function(msg){
            $("#container").ajaxComplete(function(event, request, settings)
            {
                $("#container").html(msg);
            });
        }
    });
}

I am using this code to apply "edit in place" which is currently working, but the only thing which is not working is when I want to reload the table with the new value.

$(".edit_tr").live('click',function(){
    var ID=$(this).attr('id');

    $("#first_"+ID).hide();
    $("#first_input_"+ID).show();
    var first=$("#first_input_"+ID).val();

}).live('change', function(){
    var ID=$(this).attr('id');
    var first=$("#first_input_"+ID).val();
    var dataString = 'id='+ ID +'&thename='+first;

    var initName = $("#hidden_first_input_"+ID).val();

    $.ajax({
        type: "POST",
        url: "edit_page.php",
        data: dataString,
        cache: false,
        success: function(html){
              alert(html); // the alert is not coming. even put any process, nothing happen
        }
     });
});

But the values is updating into the database. I have to refresh, and call the table one more time using JQuery then the value will be updated. Or I can click the paging, then it will be correct. ANy idea why is this happening? Thank you in advance!

2
  • Whats the edit_page.php supposed response to the post?
    – Jay Rizzi
    Feb 20, 2013 at 4:55
  • just a new value updated to database...
    – UserProg
    Mar 22, 2013 at 3:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.