XMLHTTP [英] XMLHTTP

查看:56
本文介绍了XMLHTTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在页面上动态更新HTML的好方法(不离开

页面)是在JavaScript中使用document.innerHTML和XMLHTTP,然后

与服务器通过XML片段(加上一些服务器端

脚本当然,我使用的是PHP5 + MySQL)。如果你想看一个例子,你可以看看我的聊天:
http://blog.outer-court.com/chat/


(我的灵感来自Google Suggest,使用XMLHTTP。)


当然,这也可用于表单验证和类似任务。

解决方案

< blockquote>


Philipp Lenssen写道:

一种在页面上动态更新HTML的好方法(无需离开
页面)是在JavaScript中使用document.innerHTML和XMLHTTP,


document.innerHTML?是否有任何浏览器提供其他任何东西,但

未定义该表达式?

我想你在元素节点上使用element.innerHTML。

then
通过XML片段与服务器通信(加上一些服务器端的脚本当然,我使用的是PHP5 + MySQL)。如果你想看一个例子,
你可以看看我的聊天:
http://blog.outer-court.com/chat/




不太适合国际聊天 ;,我输入了欧元字符

''?'',然后在泡沫中反映为''%u20AC''。用

输入文字。因此,虽然XML片段应该为您提供使用UTF-8并且在字面上使用此类字符并且在您的应用程序中没有转换

问题的可能性,但似乎存在问题。

-


Martin Honnen
http://JavaScript.FAQTs.com/





Philipp Lenssen写道:

在页面上动态更新HTML(不离开
页面)的好方法是在JavaScript中使用document.innerHTML和XMLHTTP,然后与之通信服务器通过XML片段(加上一些服务器端
脚本当然,我使用的是PHP5 + MySQL)。如果你想看一个例子,
你可以看看我的聊天:
http://blog.outer-court.com/chat/




使用Mozilla浏览器此功能


函数checkKey(e)

{

var returnKey = 13;

var characterCode = -1;


if(e&& e.which)

{

e = e;

characterCode = e.which;

}

else

{

e = event;

characterCode = e.keyCode;

}


if(characterCode == returnKey)

{

saySomething();

}

返回false;

}


导致错误消息相似


错误:事件未定义

源文件: http://blog.outer-court.com/chat/dynamic.js

L ine:275


在脚本控制台中,所以你需要将其更改为


function checkKey(evt)

{

var returnKey = 13;

var characterCode = -1;


evt = evt || window.event;


if(evt.keyCode){

characterChode = evt.keyCode;

}

else if(evt.charCode){

characterCode = evt.charCode;

}

else if(evt.which) {

characterCode = evt.which;

}


if(characterCode == returnKey)

{

saidSomething();

}

返回false;

}

Crosspost / followup-to comp.lang.javascript。


-


Martin Honnen
http://JavaScript.FAQTs.com/

Philipp Lenssen写道:

在页面上动态更新HTML(不离开
页面)的好方法是在JavaScript中使用document.innerHTML和XMLHTTP,然后
通过XML片段与服务器进行通信(加上一些服务器端的脚本当然,我使用的是PHP5 + MySQL)。如果你想看一个例子,
你可以看看我的聊天:
http://blog.outer-court.com/chat/ (我的灵感来自使用XMLHTTP的Google Suggest。)


这对于特定于IE的有限受众应用程序来说很好,而且我已经使用了它,但它对于更广泛的受众来说是没用的。查看Google Suggest

代码,了解他们首先要了解的内容,以确定是否可以使用
XMLHTTP。看起来他们可能已经为每种浏览器提供了解决方案

,尽管我不会花时间来解释他们的混淆代码。

当然,这也可用于表单验证和类似任务。



A nice way to dynamically update HTML on a page (without leaving the
page) is to use document.innerHTML and XMLHTTP in JavaScript, then
communicate with the server via XML snippets (plus some server side
scripts of course, I use PHP5+MySQL). If you want to see an example,
you can take a look at my chat:
http://blog.outer-court.com/chat/

(And I was inspired by Google Suggest, which uses XMLHTTP.)

Of course, this can also be used for form validation and similar tasks.

解决方案



Philipp Lenssen wrote:

A nice way to dynamically update HTML on a page (without leaving the
page) is to use document.innerHTML and XMLHTTP in JavaScript,
document.innerHTML? Is there any browser giving anything else but
undefined for that expression?
I suppose you use element.innerHTML on an element node.
then
communicate with the server via XML snippets (plus some server side
scripts of course, I use PHP5+MySQL). If you want to see an example,
you can take a look at my chat:
http://blog.outer-court.com/chat/



It is not quite up to "international chat", I entered the Euro character
''?'' and that was reflected as ''%u20AC'' then in the "bubble" with the
entered text. So while XML snippets should give you the possibility
using UTF-8 and using such characters literally and without conversion
problems in your app there seems to be a problem with that.
--

Martin Honnen
http://JavaScript.FAQTs.com/




Philipp Lenssen wrote:

A nice way to dynamically update HTML on a page (without leaving the
page) is to use document.innerHTML and XMLHTTP in JavaScript, then
communicate with the server via XML snippets (plus some server side
scripts of course, I use PHP5+MySQL). If you want to see an example,
you can take a look at my chat:
http://blog.outer-court.com/chat/



With Mozilla browsers this function

function checkKey(e)
{
var returnKey = 13;
var characterCode = -1;

if(e && e.which)
{
e = e;
characterCode = e.which;
}
else
{
e = event;
characterCode = e.keyCode;
}

if(characterCode == returnKey)
{
saidSomething();
}
return false;
}

causes error messages alike

Error: event is not defined
Source File: http://blog.outer-court.com/chat/dynamic.js
Line: 275

in the script console so you would need to change that to

function checkKey (evt)
{
var returnKey = 13;
var characterCode = -1;

evt = evt || window.event;

if (evt.keyCode) {
characterChode = evt.keyCode;
}
else if (evt.charCode) {
characterCode = evt.charCode;
}
else if (evt.which) {
characterCode = evt.which;
}

if(characterCode == returnKey)
{
saidSomething();
}
return false;
}

Crosspost/followup-to comp.lang.javascript.

--

Martin Honnen
http://JavaScript.FAQTs.com/


Philipp Lenssen wrote:

A nice way to dynamically update HTML on a page (without leaving the
page) is to use document.innerHTML and XMLHTTP in JavaScript, then
communicate with the server via XML snippets (plus some server side
scripts of course, I use PHP5+MySQL). If you want to see an example,
you can take a look at my chat:
http://blog.outer-court.com/chat/ (And I was inspired by Google Suggest, which uses XMLHTTP.)

That''s fine for IE-specific limited-audience applications, and I''ve used
it, but it''s useless for a broader audience. Look at the Google Suggest
code to see what hoops they jump through to find out first whether
XMLHTTP is even available. It looks like they probably have work-arounds
for each kind of browser, though I''m not going to take the time to
interpret their obfuscated code.
Of course, this can also be used for form validation and similar tasks.



这篇关于XMLHTTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆