javascript - Open a Bootstrap Modal with a PHP Variable without site reload -



on project website can report posts clicking on report button. if this, bootstrap modal pop up, have choose reason , have chance comment on this.

problem is, site reloads after clicking on button because modal needs file name, in order put in mysql databases. enough describing! here is: ( you: 'melden' german reporting :) )

echo "<a href='download.php?action=melden&name=$row[name]' class='btn btn-warning'>melden</a><p>   </p>"; 

so after clicking on button, site reloads , calls action 'melden' variable of file name.

if($_get['action'] == "melden") { if(isset($_get['name'])){     $name = $_get["name"]; 

then site gets action, saves get-variable , opens modal. after user entered reason , has commented on incident, has press 'send', in order send report.

so php site waits press of 'send' button , writes whole report mysql database

if (isset($_post["send3"])) {   if(isset($_post['dateititel']) , isset($_post['grund'])){        $grund = $_post['grund'];       $dateititel = $_post['dateititel'];        $kommentar = nl2br($_post['kommentar']); 

all works charm, want method avoid reloading of page. possible modals shows pressing button( variable of file name)? perfect!

thanks in advance! ~max

if want avoid page reloading when sending information server, suggest ajax. jquery makes sending data server simple.

here's short example how work.

$.ajax({   method: "post",   url: "some.php",   data: { name: "john", location: "boston" } })   .done(function( msg ) {     alert( "data saved: " + msg );   }); 

here we're sending name , location server in json, in php decode json need decoded data , send corresponding data (in json format) client.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -