ajax返回[object Object]的处理办法

2018-08-18 12:24:52
Reading:336

ajax加载失败返回[object Object],此时可以用error或complete接收返回结果data,用data.responseText将返回结果作为String,显示出来,或做其它处理。

<script>
function addrow(id){
	try {
		$.ajax({
			url : "getrow.php",
			type : "post",
			data : "id=" + id,
			dataType : "html",
			error : function(msg) {
				alert('加载失败:'+msg.responseText);
			},
			success : function(msg) {
				//
			}
		});
	} catch (err) {
		alert(err.description);
	}
	return true;
}
</script>

About

When I was young
I'd listen to the radio
Waiting for my favorite songs
When they played I'd sing along
It made me smile
Those were such happy times
And not so long ago
How I wondered where they'd gone
But they're back again
Just like a long lost friend
All the songs I loved so well