-1

I have one table, and when I click on row, it loads some content in another table.

The problem is, when I click on row the first time it loads just one time (message 'Some msg' and message 'Some other msg' is shown one time). When I click on another row, it loads twice (messages is shown twice). The third time when I click on row it loads three times, etc.

Here is my code:

$("#myTable tr").click(function(e){
    $.ajax({
        url:'<?php echo $full_path_ajax_php; ?>',
        data:{'what':'2','mypath':'12345678'},
        dataType:'json',
        type: 'GET',
        beforeSend:function(){alert('Some msg')},
        success: function(){alert('Some other msg')}
    });
    return false;
});

2 Answers 2

0

Try to use id instead of 'tr', and you will get the id in function's click event. I think this may work, correct me if I'm wrong.

Sign up to request clarification or add additional context in comments.

4 Comments

I do not understand what are you suggesting, can you give an example? But still think that isnt solution.Tnx
I try to use 'id' instead of 'tr',still dont work,can someone help me with this,it is annoying,...
hey do you have child tables within #myTable ??
No,I dont have.Starx solve my problem,thank you for your time Chirag
-1

You need to use the .live() function in the parent table but don't use this code in the portion which you are going to use:

$("#myTable tr").live('click', function(e){
    $.ajax({
        url:'<?php echo $full_path_ajax_php; ?>',
        data:{'what':'2','mypath':'12345678'},
        dataType:'json',
        type: 'GET',
        beforeSend:function(){alert('Some msg')},
        success: function(){alert('Some other msg')}
    });
    return false;
});

Remember, only once in the parent page or table.

2 Comments

Tnx man,that work fine,I'll look live event to understand it better my problem.Tnx.
I think that I dont have enough reputation :(

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.