In the below posts, I'm adding string #show-post
to the current URL .I will have a simple function to trigger a pop up box when the string present in the URL. This is an alternative idea as $(".posts-popup").trigger('click');
is not working oddly, its placed in the success function of ajax.
ANd this adds the string multiple time like this:
http://localhost/homepage.php#show-post#show-post#show-post#show-post#show-post#show-post#show-post#show-post#show-post#show-post#
ANd problem with adding the string to URL, each time the page is reloaded and the string is present, this pop up box function triggered. SO I'm looking for a way to remove the string from URL when other ajax calls are made.
window.location.href.split(/[?#]/)[0];//to remove the string.
I referred here: Remove querystring from URL I thought this would, immediately remove the string when I place this in the ajax success function, but it doesn't remove at all.How to use this then?
//string added in the success function of ajax
$("input[name^=delete2]").on("click",function()
{
var deleteMe = this.id;
$.ajax({
dataType: "text",
url: '/delete_this.php?id='+deleteMe,
success: function(data){
//$(".posts-popup").trigger('click');
window.location = window.location.href + "#show-post";
window.location.reload();
}//end sucess
});//end ajax
});