I needed to update the text within each span that has the done_by class, so I decided to utilize Ajax.
For some specific reasons, I have to send the ID of each span to my display_name.php. The ID consists of two numbers separated by an underscore, which is why I will be using the .split
method.
Here is the code snippet:
$('.done_by').each(function()
{
temp = $(this).attr('id').split("_");
$.post("../functions/ajax/display_name.php",
{
id_case: temp[0],
id_task: temp[1]
},
function(data,status){
$(this).html(data);
//alert("Data: " + data + "\nStatus: " + status);
});
});
The values of id_case and id_task are successfully sent to display_name.php.
I am unsure about the syntax of $(this).html(data);
Currently, it does not display anything. However, when I use alert(data), it shows everything correctly. I suspect there might be a syntax error in my code.