1

I have a fully functioning .php which utilizes XMLHttpRequest to Post data back to itself. What I'm looking to do is making the response a little more friendly for the user rather than me simply displaying a JS alert() when the function completes.

How can/should I access particular portions in the response rather than the entire response. For example, I could...

document.getElementById('result').innerHTML = "Received:<br>\n" + xmlhttp.responseText;

...to grab all of it. Can I simply pull individual pieces out with document.getElementByid()??

Thanks.

4

1 回答 1

0

您不能在 responseText 上调用这些方法,但可以在 responseXML 上调用它们 - 请参阅http://msdn.microsoft.com/en-us/library/ms534370(v=vs.85).aspx示例。responseXML 属性将包含一个 DOM,您可以在其中使用标准 DOM 方法(当然,假设您的服务器实际上正在发送回 XML - 如果没有,您需要自己解析 responseText)

于 2013-01-30T22:40:54.430 回答