0

APKでjavascriptを介してphpを呼び出す方法、私はwebwiewとhtml5 javascriptとjqueryを使用しています

phpからjsonデータを取得したい

function ajaxFunction() {
    DefaultHttpClient httpclient = new DefaultHttpClient();
    httpclient.addRequestInterceptor(new RequestAcceptEncoding());
    httpclient.addResponseInterceptor(new ResponseContentEncoding());
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://www.smartcloudinfo.com/game/RainbowTreasure(IPAD)/RT_IPADV1.0.40/json.php");
        try {
            // Add your data
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("line_value",20));
            nameValuePairs.add(new BasicNameValuePair("stake_value",0.2));
            nameValuePairs.add(new BasicNameValuePair("balance_value",updated_Balance));  
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            // Execute HTTP Post Request
            HttpResponse response = httpclient.execute(httppost);
             alert("found"+HttpResponse response);
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
        } catch (IOException e) {
            // TODO Auto-generated catch block
        }
     }
4

1 に答える 1

0

ajaxを使用する必要があります。Jquery には、ajax 呼び出しを行う機能が組み込まれています。特に、回答をjsonに投稿したい場合は、そのようなことを行うための jquery の呼び出しもあります。

jquery ページの簡単なサンプルを次に示します。

$.ajax({
  url: "test.html",
  context: document.body
}).done(function() {
  $(this).addClass("done");
});

または JSON の場合:

$.getJSON("test.js", { name: "John", time: "2pm" }, function(json) {
    alert("JSON Data: " + json.users[3].name);
    });
于 2013-02-04T07:16:29.823 に答える