Home  >  Article  >  Web Front-end  >  , is ajax invalid in html? Is there any other way to replace it? _html/css_WEB-ITnose

, is ajax invalid in html? Is there any other way to replace it? _html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:50:211036browse

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <title></title>	<script type='text/javascript' src='js/jquery-1.11.1.js'></script>  </head>    <body>   <table>			<tr>				<td> 					注册类型: 					<input type="text" size="50" value=""						name="flag" id="flag" />				</td>			</tr>			<tr>				<td>					用户帐号:					<input type="text" size="50" value="" name="account"						id="account" />				</td>			</tr>			<tr>				<td>					用户密码:					<input type="text" size="50" value=""						name="passwd" id="passwd"/>				</td>			</tr>			<tr>				<td>					用户姓名:					<input type="text" size="50" value=""						name="name" id="name" />				</td>			</tr>			<tr>				<td>					vcode:					<input type="text" size="50" value="" name="vcode"						id="vcode" />				</td>			</tr>			<tr>				<td>					App开发ID:					<input type="text" size="50" value="" name="agent"						id="agent" />				</td>			</tr>						<tr>				<td align="center">					<input type='button' value='提交' onclick='sendMsg()' />				</td>							</tr>		</table>  </body>    <script  type="text/javascript">    function sendMsg() {    var flag = document.getElementById("flag").value;    var account = document.getElementById("account").value;    var passwd = document.getElementById("passwd").value;    var name = document.getElementById("name").value;    var vcode = document.getElementById("vcode").value;    var agent = document.getElementById("agent").value;                    var	msg = "{"\"flag\": \""+flag+"\"," +			"\"account\":\""+account+"\",\"passwd\":\""+passwd+"\","+			"\"name\":\""+name+"\",\"vcode\":\""+vcode+"\","+			"\"agent\":\""+agent+"\"}";    	 $.ajax({ 			type : 'post', 			url  : 'http://222.161.197.250:80/register',  		    data : msg, 		    dataType:'json',  		   contentType: "application/json", 			success : function(data){     			alert("注册成功"); 		    }, 		    error : function(req, textStatus, errorThrown) { 	 		    console.log(req); 		    	if(req.responseJSON!=null){ 		    		alert("提交失败,错误编号:" + req.responseJSON.error + "错误原因:" + req.responseJSON.error_desc); 		    	}else{ 		    		alert("注册成功"); 		    	} 		    } 	    });     } </script></html>


Reply to discussion (solution)

Debugging, var msg = "{""flag": "" flag "" ," No need to put quotation marks

Can you tell me how to print out the request information and feedback information on the page

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn