Ajax和javascript之间混淆 [英] Confused between ajax and javascript
问题描述
我在编码一个简单的输入文本框时感到困惑,因为输入框
邮政编码,然后显示带有其地图API的Google地图.
我起初以ajax为初衷,但是当我这样做的时候,我发现了
我最终得到了一个javascript函数,该函数接受了表单中的邮政编码.
该功能只是从邮政编码输入中初始化map元素,我可以在其中将其显示在页面上.
我的文本框中有一个onkeyup参数,该参数调用如下函数:
Hi,
I am getting kind of confused as I was coding a simple input text box that takes in
a zip code, which then displays a google map with its map api.
I initially started out with ajax in mind, but as i was doing it, I found
that i ended up with a javascript function that takes in the zip code from my form.
The function just initializes the map element from the zip code input, where I can just display it on the page.
My text box has an onkeyup parameter that calls the function as below:
function initialize(str) {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map_canvas"));
var geocoder = new GClientGeocoder();
geocoder.setBaseCountryCode("us");
geocoder.getLatLng(
str,
function(point) {
if (point) {
map.setCenter(point, 13);
var marker = new GMarker(point);
map.addOverlay(marker);
}
}
);
}
}
我的概念可能不那么强,所以这个document.getElementById
部分是什么?那是JavaScript吗?
那么,为什么我们需要ajax?对于不支持javascript的情况?
感到困惑.
Brian
I''m probably not that strong in my concepts, so what''s this document.getElementById
part? Is that a javascript thing?
So why do we need ajax then? For cases where javascript is not supported?
Confused.
Brian
推荐答案
document.getElementById
是JavaScript.如果您希望在不离开该页面的情况下访问页面上的服务调用(不回发),则使用Ajax.该ajax(服务器端编码)调用仍由javascript(客户端编码)处理.
http://www.webdeveloper.com/forum/archive/index.php/t- 178422.html [ ^ ]
Thedocument.getElementById
is a javascript. Ajax is used if you want a service call accessed on your page without leaving that page (no-postback). That ajax (server side coding) call is still handled by javascript(client side coding).
http://www.webdeveloper.com/forum/archive/index.php/t-178422.html[^]
document.getElementById
是Java语言.
AJAX是使用Javascript从客户端与服务器进行通信的一种方式.
要了解有关AJAX及其用法的更多信息,请看这里: AJAX Tutporial [此处. [
document.getElementById
is a Javascript thing.
AJAX is a way to communicate with server from client using Javascript.
To read more on AJAX and how it is used, look here: AJAX tutporial[^]
More details here.[^]
尝试此链接
单击此处 [
try this Link
Clickhere[^]
这篇关于Ajax和javascript之间混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!