How to only send Ajax requests
Hey,
I am working on a little mobile site for my own home-built home automation system. Essentially I'd like to have a bunch of listviews that, when tapped, send an Ajax request to a server and does not load in any data or create a new page. This is so I can send TV remote control commands, turns lights on and off, set AC, etc.
Snippet of code of the listview:
- <li data-theme="c">
- <a href="#page1" data-transition="slide" id="lightsOff">
- Lights Off
- </a>
- </li>
And then the script:
- <script>
- $(document).ready(function() {
- $("#lightsOff").tap(function(){
- $.mobile.loadPage( "api/see/light/off.php",{reloadPage:true,type:"get"} );
- });
- });
- </script>
Two questions:
1) Is there a way to prevent the pages from loading into DOM, as I am simply sending AJAX and don't care about the response? If not, can I delete the pages from the DOM? If I use this as a remote control, I could end up with thousands of pages over the course of a day or three.
2) Any way to keep the listview item from staying selected after a click? I'd like it to briefly show as blue (selected), then go back to the normal color.