Nu börjar det likna någonting... jag får PHP error från alla webbläsare... detta error beror på att den inte får in någon url till klassen. url'en som ska in är den som finns i value="" i select.
Nu är vi nära
ser ut så här nu
Kod:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Ajax</title>
<script type="text/javascript" src="js/fetch.js"></script>
</head>
<body>
<form id="feeds" action="index.html" method="post">
<select id="feed" onchange='xmlhttpPost("show_feed.php")'>
<option value="">Välj</option>
<option value="http://www.geiser.se/feed">Geiser.se</option>
<option value="http://feeds.feedburner.com/tkjblogg?format=xml">TkJ</option>
<option value="http://www.dan.se/feed">Dan.se</option>
</select>
</form>
<div id="result"></div>
</body>
</html>
Kod:
function xmlhttpPost(strURL) {
* *var xmlHttpReq = null;
try
{
xmlHttpReq = new XMLHttpRequest();
}
catch (e)
{
try
* {
* xmlHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
* }
catch (e)
* {
* xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
* }
}
* *xmlHttpReq.open('POST', strURL, true);
* *xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
* *xmlHttpReq.onreadystatechange = function() {
*
* if (xmlHttpReq.readyState == 1) {
* * * * * *updatepage('<br /><br /><img src="loader.gif" border="0" alt="" style="margin-left:15px;" />');
* * * *}
*
* * * *if (xmlHttpReq.readyState == 4) {
* * * * * *updatepage(xmlHttpReq.responseText);
* * * *}
* *}
* *xmlHttpReq.send(getquerystring());
}
function getquerystring() {
var form = document.getElementById("feeds");
var feeds = form.elements["feed"];
var selectedFeed = feeds.options[feeds.options.selectedIndex].value;
return selectedFeed;
}
function updatepage(str){
* *document.getElementById("result").innerHTML = str;
}