Error updating part of the page

I have been using sending via ajax for a long time, but this has never happened: sending happens only once, and then when you click on a div (class .msgdel), it simply reloads the page.

$('.msgdel').click(function () {
    var id = $(this).attr('id');
    var data = "comid=" + id;
        type: "POST",
        url: "comdel.php",
        cache: false,
        data: data,
        success: function (html) {
            $('div#commentsdiv').load("# div#commentsdiv");
    return false;

How to fix this line? Everything is fine without her. How to update a specific div?

$('div#commentsdiv').load("# div#commentsdiv");

Answer 1, authority 100%

Perhaps I’m not well versed in js and jquery in particular, but I don’t understand the construction:

$('div#commentsdiv').load("# div#commentsdiv");

more precisely, what it should do.
for the rest:

  1. it is possible that .msgdelis inside the container #commentsdivthen of course click will go astray, it is treated simply instead of



  2. loading content into the desired block is done in your case like this:

    success: function(html){$('div#commentsdiv').html(html);

Answer 2, authority 100%

In your example, _POSTgoes to the yyy.php file. But judging by the structure of the index.php file,

... [] ...
... [Include <FORM>]...
... [Include ]...

Something hellish happens after you check and write data to the database, stick the redar function with an index and see what happens, you will understand by trial and error. And even easier, just experiment on bare raw materials!

You can throw a header anywhere, at least on a small software site, at least on a php file, I added information about this function in response! The main thing that you should understand in working with header is that it edits the HTTP header for you, and for example ECHO and PRINT, you cannot use it before header’a.

Leave a reply

Please enter your comment!
Please enter your name here