I have a list, and when someone clicks on the li element and then on $ .ajax (), I get the data he needs.
for ie:
<li id="test1">test 1 </li>
<li id="test2">test 2 </li>
<li id="test3">test 3 </li>
...
<li id="testN">test N </li>
So, the ajax part is for test 1:
$('#test1').click(function() {
$.ajax({
url: 'fetch.php',
type: 'POST',
data: { temp : 'test1'},
success: function(data) {
$('#test1').append(data);
}
});
and the same for 2,3,4 ... N
But the problem is that this is too much code ... just paste the paste, but can I do it differently? value when i click the element test1 jQuery detects which element i clicked and runs for it ...
Sorry my bad english thanks
source
share