Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery.post doesn't work

Tags:

jquery

php

.post

HTML element:

<img align="center" onclick="doc()" src="images/doc.png">

JavaScript function:

function doc (){
    $.post("php/file.php", { name: "John", time: "2pm" },).done( function(data) {
        alert("Data Loaded: " + data);
    });
}

file.php:

$pi=$_POST['name'];
echo ($pi);

I don't know why, but $.post doesn't send data when I click on the image it doesn't do anything

like image 534
user2090823 Avatar asked May 16 '26 01:05

user2090823


1 Answers

 function doc (){
  $.post("php/file.php", { name: "John", time: "2pm" })
   .done( function(data) {
    alert("Data Loaded: " + data);
    }); 
  }
like image 145
EnterJQ Avatar answered May 18 '26 15:05

EnterJQ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!