In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "what are the common minor problems in Ajax". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what are the common minor problems in Ajax?"
The 1.ajax cross-domain passing value is required. The type of return is jsonp.
$.ajax ({url: "http://.......",type: 'GET',dataType:' JSONP',//js cross-domain value success: function (data) {}}))
DataType
Type: String
The type of data expected to be returned by the server. If not specified, jQuery automatically determines intelligently based on the MIME information of the HTTP package, such as the XML MIME type is recognized as XML. In 1. 4, JSON generates a JavaScript object, and script executes the script. Then the data returned by the server side will be based on the
After this value is parsed, it is passed to the callback function. Available values:
"xml": returns the XML document, which can be processed with jQuery.
"html": returns plain text HTML information; the included script tag is executed when the dom is inserted.
"script": returns plain text JavaScript code. The results are not automatically cached. Unless the cache parameter is set. Note: when making remote requests (not in the same domain), all POST requests will be converted to GET requests. (because the script tag of DOM will be used to load)
"json": returns JSON data.
"jsonp": JSONP format. When calling a function in the form of JSONP, such as "myurl?callback=?" Will jQuery be replaced automatically? Is the correct function name to execute the callback function.
A demo sample of 2.ajax works with php to get the value.
$(function () {var my_data= "foreground variable"; my_data=escape (my_data) + ""; / / coding to prevent Chinese characters from garbled $.ajax ({url: "ajax_php.php", type: "POST", data: {trans_data:my_data}, / / dataType: "json", error: function () {alert ('Error loading XML document');}, success: function (data,status) {/ / if php is successfully called alert (unescape (data)) / / Decoding, displaying Chinese characters}});})
Php code
$backValue=$_POST ['trans_data']; echo $backValue. "+ backend return"
Data conversion processing of json in 3.php
Json_decode (string $json [, bool $assoc]); / / accepts a string in JSON format and converts it to a PHP variable
Json_decode ($data,true)
Json A string in json string format to be decoded. Assoc when this parameter is TRUE, it returns array instead of object.
Json_encode (mixed $value [, int $options = 0]) returns the JSON form of the value value
Json_encode ($a)
The above is all the contents of the article "what are the common problems in Ajax?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.