Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8281919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:12:04+00:00 2026-06-08T10:12:04+00:00

Hello guys I’m trying to sending my JSONArray to php page I’m getting HTTP//1.1

  • 0

Hello guys I’m trying to sending my JSONArray to php page
I’m getting HTTP//1.1 200 but I still can’t show it in my php page and I still didn’t know I have succeed to send it or not
here is my android code

public void sendJson() {

                HttpClient client = new DefaultHttpClient();
                HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); //Timeout Limit
                HttpResponse response;

                try{
                    HttpPost post = new HttpPost("http://sap-sp-test.dff.jp/sp.php/ranking/index");
                    Log.i("entry", MixiActivity.entry.toString());

                    ArrayList<NameValuePair> nVP = new ArrayList<NameValuePair>(2);  
                    nVP.add(new BasicNameValuePair("json", MixiActivity.entry.toString()));
                    post.setEntity(new UrlEncodedFormEntity(nVP));
                    response = client.execute(post);
                    Log.i("postData", response.getStatusLine().toString());
                }
                catch(Exception e){
                    e.printStackTrace();
                    Log.i("error", e.getMessage());
                }

    }

PHP code

$data =  $_POST['json'];
echo $data;

I already tried some example here but I still can’t sent the data
and the JSON array(MixiActivity.entry) is not empty
when I try to print it with log,the log show the right value of the JSON array
but I just can’t send it to the PHP
please help me with this problem

Thanks a lot

Niko

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T10:12:05+00:00Added an answer on June 8, 2026 at 10:12 am

    Finally I gave up with http post in android
    now I’m using javascript to get the jsonarray from android

    with this

    public class JavaScriptInterface {
    Context mContext;

             JavaScriptInterface(Context c) {
                 mContext = c;
             }
    
             public String load() {
                 String JS = JsonArray.toString();
                 return JS;
             } }
    

    and in the HTML

     function loadJSON()        
    {           
    var jsonData = Android.load();
    var myDictionary = [];          
    myDictionary["jsonData"] = jsonData;
    
    post(myDictionary, "http://sap-sp-test.dff.jp/sp.php/ranking/index?user_id=" + user_id+"&display_name=" + display_name + "&photo=" + photo +"&device=android", "post");         
    }
    

    for the post to PHP I’m using form POST in the javascript

    function post(dictionary, url, method) 
            {
                method = method || "post"; // post (set to default) or get
    
                // Create the form object
                var form = document.createElement("form");
                form.setAttribute("method", method);
                form.setAttribute("action", url);
    
                // For each key-value pair
                for (key in dictionary) {
                    //alert('key: ' + key + ', value:' + dictionary[key]); // debug
                    var hiddenField = document.createElement("input");
                    hiddenField.setAttribute("type", "hidden"); // 'hidden' is the less annoying html data control
                    hiddenField.setAttribute("name", key);
                    hiddenField.setAttribute("value", dictionary[key]);
                    form.appendChild(hiddenField); // append the newly created control to the form
                }
    
                document.body.appendChild(form); // inject the form object into the body section
                form.submit();
            }
    

    and in the PHP for receiving the json

    if($this->_getParam('device') == "android")
            {
                $data = $_POST["jsonData"];
                $data = stripslashes($data);
                $friends = $data;
            }
    

    and this method works for me
    anyway thanks mariachi for your help

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello guys I can't provide the code but you can see it on the
Hello guys. I think it isn't possible just using PHP, but just to be
hello guys I am trying to extract all the anchor links from aol but
Hello guys I have a map like this http://sinanisler.com/demo/map/ and as you can see
Hello guys i'm facing a isolated exception when trying to edit my UI it
Hello guys i try to get an object global/persistent over more than one php
Hello Guys I am trying to figure out why i am gettings this error
Hello guys. I trying set EditText to input only numbers and point ( .
Hello guys can anyone help me with the issue im having with installation of
Hello guys i'm having one hell of a time trying to parse an xml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.