I have a div with id trigger in my page. I have a php file action.php which will delete contents in my text file mytext.txt. I want to do that when I click trigger using jQuery. Or is there any function to do that without PHP file?
2 Answers
You can bind a click handler to your DIV. It's actually better if you had a link instead, but not essential (i.e. - html5)
$('#trigger').click(function(){
$.get('action.php', {}, function(data){ //populate {} if you want to send any data
alert(data);//whatever your action.php file echoes out.
});
});