PHP and ajax do not update

I have an ajax request that looks like this:

$('input.fakecheck').click(function(){
alert("deleteing....");
$.ajax({
    url:"/search",
    type:"POST",
    data: $(this).attr('name')+"="+$(this).attr('value')+"&remove=Remove",
    success:function() {
        alert(data);
    }
})

})

This calls the php function, which looks like this:

private function _remove_from_short_list($cv_array)
    {
        if (is_array($cv_array))
        {
            $short_list = $this->session->userdata('short_list');
            $new_list = array_diff_key($short_list, $cv_array);
            $this->session->set_userdata('short_list', $new_list);

        }
    }

Essentiallty what happens is that on my page I have a list, which is essentially an identifier list pulled out of the session, then the user can click and enter (this will change) to remove the identifier from their session. However, as soon as the deletion has occurred, I want to update the list to show that it has occurred, currently nothing happens until I update manually.

+3
source share
5 answers

Usually you want to run something in the success function to change the list.

, ,

<ul>
    <li>
        <input id="1" type="checkbox" class="fakecheck" />
    </li>
    <li>
        <input id="2" type="checkbox" class="fakecheck" />
    </li>
</ul>

li ,

$(this).parent().remove()

AJAX. HTML- , , .

Pointy, , , , .

+2

, , - "" . (Javascript), , , , , , , "".

0

, javascript.

0

, JS HTML . HTML, PHP ​​:

function  HandleResponse(response, target)
{
  document.getElementById(target).innerHTML = response;
}
0

, , , , , .

, PHP, .. PHP HTML, , JavaScript. , , , JavaScript ( ajax.success), HTTP- .

: PHP JavaScript , Ajax, PHP - , , , .

0

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


All Articles