问题
this is my situation. I'm writing an webinterface in codeigniter to send commands to a virtual server. these commands are passed through the browser in an url.
example : http://server.com/TgtSendIRCommand?id=UM-02&code=KEY_UP this server then takes action and the web interface refreshes the screenshot.
i just want to have a bunch of links in html that send this command to the browser. But if i click the links, the user has to stay on the same page. So the command is sended but there is no other interaction.
i am using codeigniter.
Any suggestions ?
回答1:
Make a view and copy this in your view:
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
</head>
<body>
<a href="#" id="myBtn">Click here!</a>
<script type="text/javascript">
$(document).ready(function(){
$("#myBtn").click(function(){
$.get("http://server.com/TgtSendIRCommand?id=UM-02&code=KEY_UP ");
});
});
</script>
</body>
</html>
Not tested but something as above should do the trick for you.
回答2:
<?php
session_start();
$_SESSION['http://localhost/profile.php'] = $_SERVER['REQUEST_URI'];
$sess=$_SESSION["email"];
$servername = "localhost";
$username = "root";
$password = "";
$dbname ="reg";
if(!isset ($sess))
{
header("Location:login.php");
exit;
}
来源:https://stackoverflow.com/questions/13085388/sending-an-url-but-staying-on-the-same-page-php-codeigniter-javascript