Want to call a PHP page when you click div?

I want to call a PHP page when a user clicks on <DIV>using AJAX. At the same time, I want to change the text of the DIV as LOADING .....

I don't know much about AJAX, so please give me details about this as well.

Thanks in advance...

+3
source share
3 answers

Using jquery you can do

$("div#id").click(function(){
 $(this).text("Loading...").load("/path/to/file.php");
});
+3
source
<div onclick="send_ajax_request(); document.getElementById('loading').style.display = 'block';"> 
  <div style="display: none" id="loading">Loading ...</div>
</div>

send_ajax_request () is your function to call an ajax request. the second statement will make the inner div visible (style = "display: none" will make it invisible by default).

0
source

Do something like.

< div class="loader" id="ajaxloaddiv">Initial data</div>

In ajax function use:

$('#ajaxloaddiv').click( function() {
    $(this).text("Loading...");
    ...
    ... do processing here
    ...
    return false;
});
0
source

Source: https://habr.com/ru/post/1787964/


All Articles