Home  >  Article  >  Backend Development  >  php用ajax为啥只能返回数字

php用ajax为啥只能返回数字

WBOY
WBOYOriginal
2016-06-13 12:30:23818browse

php用ajax为什么只能返回数字

<br />
//提交表单<br />
function subm(){<br />
		var user = $('#frm').serialize();<br />
		$.ajax({<br />
			url: 'b.php',<br />
			type: 'POST',<br />
			data:user,<br />
			contentType:"application/json",<br />
			dataType: 'json',<br />
			async:false,<br />
			beforeSend: function(){<br />
				alert('Error loading PHP document');<br />
			},<br />
			success: function(result){<br />
				alert(result);<br />
			}<br />
		});<br />
	}<br />

<br />
<form id="frm" action="" method="post" onsubmit="subm()"><br />
<input<br />
	id="user" name="username" /><br /><br />
<input id="password" type="password" name="password" /><br /><br />
<br />
<input type="submit" value="提交" /></form>



然后我在b.php页面写一个 echo '123' 回调函数可以执行alert(res) 并输出123 可是我echo写字母字符中文他就没反应了 连框都不弹  我把页面设成utf-8 在 b.php也加了header 可是他应该能返回字母跟字符 就算乱码也会弹个窗吧 是不是那个json传递的问题 求教

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