BR
asked on
how to post data with on load function with Jquery
Dear Experts,
I'd like to post the data to my php page. The below code works but I want to post it with on load function not with on click.
I want to post it when the page is loading.
How can I do that? thank you in advance.
I also want to remove the alert.
I'd like to post the data to my php page. The below code works but I want to post it with on load function not with on click.
I want to post it when the page is loading.
How can I do that? thank you in advance.
I also want to remove the alert.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$.post("test-post.php",
{
name: "Donald Duck",
city: "Duckburg0922"
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
});
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER