function Changedistrict (value) {
if (value = = 0) {
$ (' #transport_node '). empty ();
$ (' #transport_node '). Append (' <option value= "0" > Please select </option> ');
Return
}
$ (' #transport_node '). empty ();
$ (' #transport_node '). Append (' <option value= "0" > Load in ...</option> ');
$.ajax ({
Type: ' GET ',
URL: "Http://192.168.33.114:8080/UIDTraceAdmin/transportnode/pagelist/jsonp?callbackFunction=jsonpCallback",
Async:false,
DataType: "Jsonp",
JSONP: "Jsonpcallback",//pass to the request handler or page, to obtain the name of the JSONP callback function name (the general default is: callback)
Success:function (o) {},
timeout:3000
});
}
Note: This function is called after a cross-domain service-side response is returned
function Jsonpcallback (Result) {
....//The specific code omits {data: "Data"} to read the field values directly in Data.data form.
}
To process code across domain servers:
[Java] View plain copy on code to see a snippet derived from my Code slice
@RequestMapping ("/pagelist/jsonp")
public void PageList (@ModelAttribute transportnode node,httpservletrequest httpreq,
HttpSession session,httpservletresponse response) {
Return to head settings
Response.setheader ("Pragma", "No-cache");
Response.setheader ("Cache-control", "No-cache");
Response.setheader ("Content-type", "application/x-javascript;charset=utf-8");
Response.setdateheader ("Expires", 0);
String jsonpcallback = Httpreq.getparameter ("callbackfunction");//jsonp callback function name
Jsonobject Resultjson = new Jsonobject ();
PrintWriter out = null;
try {
out = Response.getwriter ();
} catch (IOException E1) {
E1.printstacktrace ();
}
try {
Node.setrowstart ((Node.getpage ()-1) * Node.getrows () + 1);
Node.setrowend (Node.getpage () * node.getrows ());
Resultjson.put ("Transportlist", Jsonutils.tojsonlist (business.getlist (node));
Resultjson.put ("Success", true);
System.out.println (Resultjson.tostring ());
Out.println (jsonpcallback+ "(" +resultjson.tostring () + ")");//return JSONP format data
Out.flush ();
Out.close ();
} catch (Exception e) {
LogWriter.log ("/pagelist/jsonp", e);
try {
Resultjson.put ("Success", false);
} catch (Jsonexception E1) {
E1.printstacktrace ();
}
Out.println (jsonpcallback+ "(" +resultjson.tostring () + ")");//return JSONP format data
Out.flush ();
Out.close ();
}
JQuery Cross-domain access