I'm new to this and I'm trying to figure out if it's possible to pass specific data values (URL's and strings) from one HTML page to another with ajax. For example say I have "Location 1.html" and I want to send a specific value (name, URL) to "List.html" that can display the values in a li listview. I would like to be able to add data from many location html files (ex. "Location 2.html", "Location 2.html", etc). I found this example but it uses ASP.
http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_ajax_post
Here is what I tried but I don't even know if it's even right.
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<style>
div.disabled {
background: lightgrey;
}
</style>
<div data-role="page" id="Location1">
<div data-role="header" data-position="fixed">
<h1>Location 1</h1>
</div>
<div role="main" class="ui-content">
<button class="rbutton" data-icon="star">Disable</button>
</div>
<div data-role="footer" data-position="fixed">
<h1>My page footer</h1>
</div>
</div>
<script>
$('.rbutton').on('click',function() {
$(this).prop("disabled",true);
$.post("List.html",
{
name: "Donald Duck",
city: "Duckburg"
},
function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
</script>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
</head>
<div data-role="page" id="Favorites">
<div data-role="header" data-position="fixed">
<h1>Favorites</h1>
</div>
<div role="main" class="ui-content">
<ul id="favorites_list"></ul>
</div>
<div data-role="footer" data-position="fixed">
<h1>My page footer</h1>
</div>
</div>
</html>