jquery - How to post a variable to a php file using ajax -


i want pass variable college.php variable can used fetch data.

i tried get , post methods using form, using get variable values visible in address bar , using form resubmission alert appears used.

<form class="morestories"method="get" enctype="multipart/form-data" action="college.php">                    <input type="hidden" name="collegename" value="<?php $collegename=$row['name']; echo $collegename; ?>">                    <input class="morestoriesbutton" type="submit" name="collegeselectlink" value="more stories" />                  </form> 

also variables passing college.php file, on refresh should used again access data possible help

this example passing name , password php function , can refer , apply accordingly condition.

$(document).ready(function(){      //this button      $("#click").click(function(){           // getting username , password html         username = $("#name").val();         password = $("#pad").val();          if(username=="" || password==""){             alert("please check details");         } else {             $.ajax({ url: 'reverse.php',                 data: {username:username,password:password},                 type: 'post',                 success: function(output) {                      alert(output);                 }             });         }     }); }); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -