apicloudAJAX 요청 코드 집합 기반
api.ajax({
url:'http://m.weather.com.cn/data/101010100.html' // WebService
},function(ret,err){
if (ret) {
api.alert({msg:JSON.stringify(ret)});
} else {
api.alert({msg:JSON.stringify(err)});
};
});
POST 요청-form 폼 제출:
api.ajax({
url: 'http://www.xxx.com/path/form',
method: 'post',
dataType: 'text', // , json
data: {
values:{name: 'devlp', password: '123456'} //
}
},function(ret,err){
if (ret) {
api.alert({msg:JSON.stringify(ret)});
} else {
api.alert({msg:JSON.stringify(err)});
};
});
POST 요청-단일/여러 파일,파일 그룹 업로드:
api.ajax({
url: 'http://www.xxx.com/path/upLoad',
method: 'post',
data: {
files:{myfile: 'filepath'}
// filepath ios Android 。 , , files:{myfile: 'filepath', myfile1: 'filepath1'} files:{'myfile[]': ['filepath', 'filepath1']}
}
},function(ret,err){
if (ret) {
api.alert({msg:JSON.stringify(ret)});
} else {
api.alert({msg:JSON.stringify(err)});
};
});
POST 요청-바 이 너 리 스 트림 제출:
api.ajax({
url: 'http://www.xxx.com/path/body',
method: 'post',
data: {
body:'textbits'
}
},function(ret,err){
if (ret) {
api.alert({msg:JSON.stringify(ret)});
} else {
api.alert({msg:JSON.stringify(err)});
};
});
POST 요청-파일 스 트림 제출:
api.ajax({
url: 'http://www.xxx.com/path/body',
method: 'post',
data: {
stream:'filepath'
// filepath ios Android
}
},function(ret,err){
if (ret) {
api.alert({msg:JSON.stringify(ret)});
} else {
api.alert({msg:JSON.stringify(err)});
};
});
POST 요청-Multiport-Data,파일 과 텍스트 필드 를 함께 제출 합 니 다.
api.ajax({
url: 'http://www.xxx.com/path/multipart',
method: 'post',
data: {
values:{name: 'devlp', password: '123456'},
files:{file: 'fs://test.png'}
}
},function(ret,err){
if (ret) {
api.alert({msg:JSON.stringify(ret)});
} else {
api.alert({msg:JSON.stringify(err)});
};
});
POST 요청-업로드 진행 상황 표시:
api.ajax({
url: 'http://www.xxx.com/path/multipart',
method: 'post',
report: true,
data: {
values:{name: 'devlp', password: '123456'},
files:{file: 'fs://test.png'}
}
},function(ret,err){
if(ret){
if(0 == ret.status){
//loading(' :' + ret.progress);
}else{
api.alert({msg:' :
' + JSON.stringify(ret)});
}
}else{
api.alert({msg:JSON.stringify(err)});
}
});
[엔 드 API 는 api.ajax 를 사용 하여 인터페이스 데 이 터 를 읽 습 니 다]
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<title>test</title>
</head>
<body>
<button onclick="showPersonInfo()"> </button>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script>
function showPersonInfo(){
api.showProgress();//
// api.ajax , , get
api.ajax({
url:'http://192.168.0.10/get.php',// ,
method:'get',
cache:'false',
timeout:30,
dataTpye:'json',
},function(ret,err){
api.hideProgress();//
if(ret){
for(var i=0;i<ret.length;i++){
var html='<br>'+'ID:'+ret[i].id+'<br>'+' :'+ret[i].name+'<br>'+' :'+ret[i].sex+'<br>'+' '+ret[i].age;
document.write(html);
}
}else{
api.alert({msg:(' :'+err.code+'; :'+err.msg+' :'+err.statusCode)});
}
});
}
</script>
</html>
이상 의 apicloudAJAX 요청 코드 모음 집 은 바로 편집장 이 여러분 에 게 공유 한 모든 내용 입 니 다.여러분 께 참고 가 되 고 저희 도 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Django와 AJAX가 웹 페이지의 동적 데이터 표시를 실현하는 예시 코드이 부분은 이미 나를 이틀 동안 괴롭혔지만 여전히 실마리가 없다. 아마도 더 오래 괴롭힐 것이다. 마지막에 3일 오전에 문제를 해결하고 눈에 띄지 않는 곳에서 구덩이가 되었다. jQuery가 불러온 문제이다.아는 사...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.