没有在Firefox中获得该页面

时间:2015-03-17 00:07:27

标签: javascript html ajax xml firefox

我正在使用XML file值开发一个简单的登录表单。我有一个值为last namefirst name的XML。我正在访问该文件并根据给定值检查值以验证登录。 它在chrome,IE和safari中运行良好。但是,在Mozilla中它没有被转发到下一页。该页面只保留在同一页面中,并显示无限期加载URL图标。

这是我的代码:



<!DOCTYPE html>
<html>

	<head>
		<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
				
		<link href="css/stylemp3.css" rel="stylesheet" type="text/css" />

	</head>
	<body>

	<form onsubmit="return myFunction()" action="action.html">
		First name:<br/>
		<input type="text" required="required" name="firstname" id="firstname"/>
			<br>
			Last name:<br>
			<input type="password" required="required" name="lastname" id="lastname"/>
			<br/>
			<select class="dropdown" id="ddl">
				<option value="haha" selected="selected">show</option>
				<option value="hihi" >hide</option>		
			</select>
			<br/>
			<input type="text" name="hide" id="hidee" class="hide"/>
			<br/>
		<input button type="submit" value="Submit"/>
	</form> 
	<div></div>
	<script>
	window.onload = function() {
  document.getElementById("firstname").focus();
};
$( "#ddl" )
  .change(function () {
    if($( "select option:selected" ).text() == "hide")
	{
	$("#hidee").hide();
	}	  
else
{
$("#hidee").show();
} 
  })
  .change();
  </script>
  <script>
  function myFunction() {
var lastname = document.getElementsByName('lastname')[0].value;
var firstname = document.getElementsByName('firstname')[0].value;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.open("GET","login.xml",false);
 
xmlhttp.send();
xmlDoc=xmlhttp.responseXML; 
var x=xmlDoc.getElementsByTagName("login");
for (i=0;i<x.length;i++)
	{
		alert(x[i].getElementsByTagName("firstname")[0].childNodes[0].nodeValue);
		if((x[i].getElementsByTagName("firstname")[0].childNodes[0].nodeValue) == firstname)
		{
			alert("Smileeee.....:-))");
			if((x[i].getElementsByTagName("lastname")[0].childNodes[0].nodeValue) == lastname)
			{
				alert("login Successful!!!!!");
				return true;
				break;
			}		
		}
	
	}
	return false;
}

</script>
</body>
</html>
&#13;
&#13;
&#13;

0 个答案:

没有答案