Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
pxlam15
Posts: 25
Registered: ‎02-04-2013
My Device: Torch
My Carrier: T-Mobile

AJAX Post

[ Edited ]

Hello All,

Seems like I was looking for/trying to do the wrong things for a while.  Right now I am trying to create a JSON array that takes in data and then sends it to a server which I want to use an AJAX post request.  I am not familiar with sending/getting information from the server so I am quite unsure what the code should look like and where it should come from.  Right now this is what I have right now and it is in a seperate class.  I have a seperate class where they input a username and password but I want to "stringify" the input for the username and password have it passed to a json object and send it to a server.  I guess I am not entirely sure how to approach this.

import java.util.Vector;

import org.json.me.JSONException;
import org.json.me.JSONObject;

public class Json
{
     public Json()
     {
     JSONObject send = new JSONObject(); 
     JSONObject JObjectData = new JSONObject();

     try
    {

    Vector name_ = null;
   JObjectData.put("Username", name_);
   Vector pwd_ = null;
   JObjectData.put("Password", pwd_); 
   send.accumulate("foo", JObjectData);


   }
  catch(JSONException e)
  {
e.printStackTrace();
}
}

}

Edit: For code formatting

Please use plain text.
Developer
simon_hain
Posts: 15,872
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: AJAX Post

i don't see any sense in your code.
json is basically key/value. Not key/vector, and in your case the vector is null, making even less sense.

i would suggest that you check out some samples
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Contributor
pxlam15
Posts: 25
Registered: ‎02-04-2013
My Device: Torch
My Carrier: T-Mobile

Re: AJAX Post

Ok!  Thanks for all your help!  I think I got a better idea of what it is now/what I am doing now.  

Please use plain text.