logo
down
shadow

How to fetch the data from the php using json in phonegap


How to fetch the data from the php using json in phonegap

By : James Dunford
Date : November 20 2020, 01:01 AM
around this issue Correct me if I am wrong but you are just asking HOW to perform this process, correct? Your question sounds like that code is from a "tutorial" and not your application? Below is how I have performed this function in one of my own private apps using PhoneGap.
My AJAX call looks like this, minus custom data manipulations:
code :
$.ajax({
    url: "http://www.mywebsite.com/myscript.php",    // path to remote script
    dataType: "JSON",                                // data set to retrieve JSON
    success: function (data) {                       // on success, do something...
        // grabbing my JSON data and saving it
        // to localStorage for future use.
        localStorage.setItem('myData', JSON.stringify(data));
    }
});
// PHP headers (at the top)
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json");

// connect to your database and perform your query    

// then build your output...
while($row = mysqli_fetch_array($result)) {
    $output[] = array (
        "id" => $row['id'],
        "firstname" => $row['firstname'],
        "lastname" => $row['lastname']
    );
}

echo json_encode($output);
var myData = JSON.parse(localStorage.getItem('myData'));
var i;

for (i = 0; i < myData.length; i = i + 1) {
   console.log(myData[i].firstname);      // this should output the firstnames.
}


Share : facebook icon twitter icon
redis storing json data with hget command .while fetching forced to fetch all json data in place of single json variable

redis storing json data with hget command .while fetching forced to fetch all json data in place of single json variable


By : Gian L
Date : March 29 2020, 07:55 AM
To fix this issue You can use hashes to store dicts in redis, than you can update only one key/value from cached_page.
code :
In [1]: import redis

In [2]: pool = redis.ConnectionPool(host='localhost', port=6379, db=0)

In [3]: r = redis.Redis(connection_pool=pool)

In [4]: r.hmset('test', {1: 'a', 2: 'b'})
Out[4]: True

In [5]: r.hset('test', 2, 'c')
Out[5]: 0L

In [6]: r.hget('test', 2)
Out[6]: 'c'
how to fetch the data from local database on the phonegap

how to fetch the data from local database on the phonegap


By : Hakampreet Singh Pan
Date : March 29 2020, 07:55 AM
should help you out Hey Please follow the below link to find a solution to your problem.
link:- http://stackoverflow.com/questions/19570868/storage-of-sqlite-database-using-android-and-phonegap
Phonegap cross domain json data calling stopped working in phonegap build

Phonegap cross domain json data calling stopped working in phonegap build


By : fgvsu
Date : March 29 2020, 07:55 AM
wish helps you You have hit a common mistake. Here is a document to help you:
Top Mistakes by Developers new to Cordova/Phonegap
Groovy JsonSlurper to fetch JSON data from URL. Error : The API package 'urlfetch' or call 'Fetch()' was not found

Groovy JsonSlurper to fetch JSON data from URL. Error : The API package 'urlfetch' or call 'Fetch()' was not found


By : prodirector
Date : March 29 2020, 07:55 AM
hope this fix your issue It works from browser since you're already authenticated. If you want it to work from command line/script you need to add authentication part as well.
getting error : fetch errorSyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data in react

getting error : fetch errorSyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data in react


By : user3437795
Date : March 29 2020, 07:55 AM
it should still fix some issue when i try to run ajax call in react js, i am getting error, fetch errorSyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data here i have placed my ajax call, can anyone please look it in my code and help me to resolve this issue ? , if it is a get request you don't need headers and mode ;
code :
fetch('https://randomuser.me/api/?results=5')
      .then(response => { return response.json(); })
      .then(responseData => { console.log( responseData ) })
      .catch(err => {
        console.log("fetch error" + err);
    });
Related Posts Related Posts :
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org