Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var JSONs = {
- example:['one','two','three']
- };
- document.write(JSONs.example[0]);
- $.ajax({
- url: "http://olympics.clearlytech.com/api/v1/medals/",
- success: function(data) {
- var json = JSON.parse(data);
- }
- });
- $(document).ready(function(){
- alert("here");
- $.getJSON("http://olympics.clearlytech.com/api/v1/medals/",function(data){
- $.each(data,function(key,value){
- alert(data[key].country_name);
- alert(data[key].rank);
- console.log(data[key].rank));
- });
- });
- });
- public void handleResponse(String response)
- {
- // display("Response:"+response);
- if(!response.equalsIgnoreCase(""))
- {
- JSONObject jso;
- try {
- jso = new JSONObject(response);
- String status = jso.getString("status");
- int valid=jso.getInt("valid");
- // display("Welcome : "+UName);
- if(valid>0)
- {
- if( status.equalsIgnoreCase("") || status==null || status.equalsIgnoreCase("Failed"))
- {
- invalid.setText("Invalid password");
- //reset();
- pwd.setText("");
- }
- else
- {
- //display(status);
- intObj=new Intent(MainActivity.this,Design_Activity.class);
- intObj.putExtra("Username", mUname);
- startActivity(intObj);
- MainActivity.this.finish();
- }
- }
- else
- {
- invalid.setText("Invalid userid");
- uname.setText("");
- }
- }
- catch (JSONException e1) {
- // TODO Auto-generated catch block
- Log.e(TAG, e1.getLocalizedMessage(), e1);
- }
- catch(Exception e)
- {
- Log.e(TAG, e.getLocalizedMessage(), e);
- }
- }
- else
- {
- display("Could not able to reach Server!");
- }
- }
- function getData(){
- // Initialize the Ajax request
- var xhr=new XMLHttpRequest();
- xhr.open('get', 'http://olympics.clearlytech.com/api/v1/medals/');
- // Track the state changes of the request
- xhr.onreadystatechange=function(){
- // Ready state 4 means the request is done
- if(xhr.readyState === 4){
- // 200 is a successful return
- if(xhr.status === 200){
- alert(xhr.responseText); // 'This is the returned text.'
- }else{
- alert('Error: '+xhr.status); // An error occurred during the request
- }
- }
- }
- // Send the request to send-ajax-data.php
- xhr.send(null);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement