Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand AJAXCALL

Shulou Source: shulou.com Published: 2022-06-03 08:36:06 11月15日 Update

This article introduces the relevant knowledge of "how to understand AJAXCALL". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Download V0.1.6 (5KMAE 2007.1.16) |

Syntax: AJAXCALL (url,handleResponse,param); give the callback data to handleResponse for processing

Parameter: url: requested address; handleResponse: callback function; doc: the document returned by AJAX; param: additional parameter (isCache: whether cache is required, default is not cached; isXML: whether to return XML document, default HTML;method: send method, default GET;attach: extension parameter, you can pass custom values, such as id of DIV, etc.)

Example 1:

AJAXCALL ("gaogao.xml", "doPostXml", "method=POST, isXML=true, isCache=true,attach=showContent")

Function doPostXml (doc,id) {

Alert (doc) / / get the returned XML document

Alert (id) / / extension parameter, the value of attach, "showContent"

If (doc) {

$(id) = getTagValue (doc,retcode)

}

}

Example 2:

AJAXCALLl ("getnews?pid=23412", "shownews", "attach=" + $('yoyo'))

Function shownews (docu,divObject) {

If (docu) {

DivObject.innerHTML=docu

} else {

DivObject.innerHTML= "system error"

}

}

Note:

If POST data, encode the data and add it to the URL, for example:

AJAXCALL ("gaogao.php?name=" + $U ('yo') + "& sex=" + male, "yoyo2", "method=POST")

AJAXFORM

Syntax: AJAXFORM (formID,handleResponse,param); AJAX POST the form data out

Parameter: formID: form ID;handleResponse: callback function, doc returns document for AJAX; param: additional parameter (isXML: whether to return XML document, default HTML;attach: extension parameter, custom value can be passed, such as DIV id, etc.)

Example:

..

Function test3 (postform) {

AJAXFORM (postform, "yoyo3", "attach=showContent")

}

Note: the data will be encoded by escape. The PHP decoding program is provided on the submission processing page.

Additional function

$('div') is equivalent to document.getElementById (' div')

F ('div') is equivalent to document.getElementById (' div'). Value

GetTagValue (XMLDoc, Tag) gets the first occurrence value of the specified TAG in the XML document

$U (str) is equivalent to encodeURIComponent (escape (str))

GetElementsByClass (searchClass,node,tag) gets an array of all nodes under a node whose CLASS is the specified name (copyright information for this function is unknown).

Get news list | Log in | submit information | read JSON | paged list (bingo+json) [upgraded V0.2] | SELECT unlimited linkage | TREE | Select query | album (unlimited playback) | multilingual switch | query drop-down prompt | tag floating prompt (imitating NetEase news display)

This is the end of "how to understand AJAXCALL". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Parameters documents data examples functions attachments information content comments news more knowledge cache coding nodes forms syntax processing prompts queries Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MySQL Linux Shulou Technology MariaDB