0

我搜索了很多我的问题,但一无所获......我有这个 ajax jquery 请求:

pan=6;
tilt=0;
zoom=0;
duration=1000;
jQuery.ajax({
   type: "GET",
   url: "//"+ip+"/cgi-bin/momentary_movement.cgi",
   dataType: "xml",
   data: "pan="+pan+"&tilt="+tilt+"&zoom="+zoom+"&duration="+duration,
   cache: false
});

我必须用 android 做到这一点。你有什么解决办法吗?我曾想过 HttpRequest 但在所有方面这都行不通

我在 Get 中尝试使用此代码:

HttpGet get = new HttpGet("http://" + ip + "/cgi-bin/momentary_movement.cgi?type=GET&datatype=xml&pan="+pan+"&tilt="+tilt+"&zoom="+zoom+"&duration="+duration+"&cache=false");

和 Post 中的这段代码:

HttpPost httppost = new HttpPost("//" + ip + "/cgi-bin/momentary_movement.cgi");
         try {
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(4);
            nameValuePairs.add(new BasicNameValuePair("type", "POST"));
            nameValuePairs.add(new BasicNameValuePair("url", "//" + ip + "/cgi-bin/momentary_movement.cgi"));
            nameValuePairs.add(new BasicNameValuePair("dataType", "xml" ));
            nameValuePairs.add(new BasicNameValuePair("data", "pan="+pan+"&tilt="+tilt+"&zoom="+zoom+"&duration="+duration ));
            nameValuePairs.add(new BasicNameValuePair("cache", "false" ));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
4

0 回答 0