- Screen name: bartjeeuhh
bartjeeuhh's Profile
6 Posts
1 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- Hi,I'm using phone gap, and I want to read a file out with the phone gap file api. I can read the file. But when I put my JSON into a variable it only returns '[]'.
- function readFS(fileSystem) {
- fileSystem.root.getFile("readme.txt", {create: true}, readFileEntry, fail);
- }
- function readFileEntry(fileEntry) {
- fileEntry.file(gotFileread, fail);
- }
- function gotFileread(file){
- readAsText(file);
- }
- function readAsText(file) {
- var reader = new FileReader();
- reader.onloadend = function(evt) {
- console.log("Read as text");
- console.log(evt.target.result);
- json = evt.target.result; // this returns only []
- navigator.notification.alert(evt.target.result); // this returns the real JSON :o
- };
- reader.readAsText(file);
- }
This is the json that's in readme.txt- {"games":[{"id":"2","name":"bartje","photo":"photo2.png","description":"kimpe","length":"is","totalDownloads":"0","totalFinished":"0","locations":[{"id":"3","name":"loc21","photo":"loc21.jpg","description":"loc21","FK_Game_id":"2","lat":"51.0000","long":"4.0000","status":"0"},{"id":"5","name":"loc22","photo":"loc22.jog","description":"locatie 22","FK_Game_id":"2","lat":"51.2330","long":"40.2222","status":"1"}]},{"id":"3","name":"aa","photo":"photo3.jPg","description":"aa","length":"aa","totalDownloads":"0","totalFinished":"3","locations":[{"id":"4","name":"loc4","photo":"loc4.jpg","description":"loc4","FK_Game_id":"3","lat":"51.2191","long":"4.4021","status":"0"}]}]}
Can please someone help me- Hey,I'm retrieving data and I encode it into JSON and put it on the website http://www.bartdekimpe.be/anoire/index.php/admin/getGamesUserJson/34 but when I want to retrieve it, eather with $.ajax or $.getJSON, it won't work.JSON:
- $.getJSON("http://www.bartdekimpe.be/anoire/index.php/games/admin/getGamesUserJson/34", function(result){
- $.each(result.games, function(){
- $(".testing").append(this.id + "<br />");
- $(".testing").append(this.name + "<br />");
- $(".testing").append(this.photo + "<br />");
- $(".testing").append(this.description + "<br />");
- $(".testing").append(this.length + "<br />");
- $(".testing").append(this.totalDownloads + "<br />");
- $(".testing").append(this.totalFinished + "<br />");
- $each(this.locations, function(){
- $(".testing").append(this.id + "<br />");
- $(".testing").append(this.name + "<br />");
- $(".testing").append(this.photo + "<br />");
- $(".testing").append(this.description + "<br />");
- $(".testing").append(this.FK_Game_id + "<br />");
- $(".testing").append(this.lat + "<br />");
- $(".testing").append(this.long + "<br />");
- $(".testing").append(this.status + "<br />");
- });
- });
- $(".testing").append(result);
- });
$.ajax()- $.ajax({
- url: 'http://www.bartdekimpe.be/anoire/index.php/admin/getGamesUserJson/34',
- dataType: 'json',
- success: function(data) {
- $(".testing").append(data);
- }
- });
- Hi,I'm making a project for school.First I get a list, which I get from an ajax call:
- function krijgSpellen(){
- $.getJSON("gegevens.txt",function(result){
- // $("#divjson").append("Game: " +result.games[1].game + " <br />Locatie: " + result.games[1].locaties[0].locatie + " <br /> Item: " + result.games[1].items[0].item + " <br /> Informatie: " + result.games[1].info );
- // Get all the games
- $.each(result.games, function(){
- $(".gamelijst").append("<li><a href='' id=" + this.id + " data-theme='a'>"+ this.game + "</a></li>");
- });
- $(".gamelijst, $.mobile.activePage").listview('refresh');
- });
- };
now when I click one of the items, I put the chosen ID in a variable, like this:- $(".gamelijst a").live("click", function(){
- currentGame = $(this).attr("id");
- $.mobile.changePage($("#locaties"));
- });
- <a href="#home" data-role="button" data-theme="c" data-icon="back" data-rel="back" data-reverse="back">back</a>
I get the game list page again, but when I choose another game, it still loads the information from my first chosen game.
I get the location information with this functions:
- function krijgLocaties(){
- gameint = parseInt(currentGame);
- $.getJSON("gegevens.txt", function(result){
- $.each(result.games[currentGame].locaties, function(){
- $(".locatielijst").append("<li><a href='' id=" + this.id + " data-theme='a'>"+ this.locatie + "</a></li>");
- });
- $(".locatielijst, $.mobile.activePage").listview('refresh');
- });
- };
- Hi,I've got a problem with the collapsible set. I'm trying to load data into it trough a JSON call but it only loads the first item correctly as header and information, and the second item he puts in the information of the first item.
- {
- "games": [
- {
- "id": "1",
- "game": "Burgermoordenaar",
- "locaties": [
- {
- "id": "1",
- "locatie": "De Keyserlei 22",
- "naam": "Quick",
- "status": "2",
- "items": [
- {
- "item": "Zakdoek",
- "info": "DNA van dhr. Jos (Hilton Hotel Groenplaats)"
- },
- {
- "item": "speeksel",
- "info": "test"
- }
- ]
- },
- {
- "id": "2",
- "locatie": "Groenplaats 32",
- "naam": "Hilton Groenplaats",
- "status": "1",
- "items": [
- {
- "item": "Getuige",
- "info": "De getuige heeft iemand herkend (mevr. Romina) - Karel De Grote Hoboken"
- }
- ]
- },
- {
- "id": "3",
- "locatie": "Salesianenlaan 30",
- "naam": "KDG Hoboken",
- "status": "0",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- }
- ]
- },
- {
- "id": "2",
- "game": "game 2",
- "locaties": [
- {
- "locatie": "locatie 2.1",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 2.2",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 2.3",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- }
- ]
- },
- {
- "id": "3",
- "game": "game 3",
- "locaties": [
- {
- "locatie": "locatie 3.1",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 3.2",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 3.3",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- }
- ]
- }
- ]
- }
function krijgInfo(){
$.getJSON("gegevens.txt", function(result){
$.each(result.games[currentGame - 1].locaties[currentLocation - 1].items, function(){
$(".infolijst").append("<div data-role='collapsible'>");
$(".infolijst").append("<h3>"+ this.item + "</h3><p>"+ this.info +"</p>");
$(".infolijst").append("</div>");
});
$(".infolijst, $.mobile.activePage").collapsible({refresh: true});
});
};
- Hi,I've got a problem with the collapsible set. I'm trying to load data into it trough a JSON call but it only loads the first item correctly as header and information, and the second item he puts in the information of the first item.
- {
- "games": [
- {
- "id": "1",
- "game": "Burgermoordenaar",
- "locaties": [
- {
- "id": "1",
- "locatie": "De Keyserlei 22",
- "naam": "Quick",
- "status": "2",
- "items": [
- {
- "item": "Zakdoek",
- "info": "DNA van dhr. Jos (Hilton Hotel Groenplaats)"
- },
- {
- "item": "speeksel",
- "info": "test"
- }
- ]
- },
- {
- "id": "2",
- "locatie": "Groenplaats 32",
- "naam": "Hilton Groenplaats",
- "status": "1",
- "items": [
- {
- "item": "Getuige",
- "info": "De getuige heeft iemand herkend (mevr. Romina) - Karel De Grote Hoboken"
- }
- ]
- },
- {
- "id": "3",
- "locatie": "Salesianenlaan 30",
- "naam": "KDG Hoboken",
- "status": "0",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- }
- ]
- },
- {
- "id": "2",
- "game": "game 2",
- "locaties": [
- {
- "locatie": "locatie 2.1",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 2.2",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 2.3",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- }
- ]
- },
- {
- "id": "3",
- "game": "game 3",
- "locaties": [
- {
- "locatie": "locatie 3.1",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 3.2",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- },
- {
- "locatie": "locatie 3.3",
- "items": [
- {
- "item": "item 1.1",
- "info": "info item 1.1"
- },
- {
- "item": "item 1.2",
- "info": "info item 1.2"
- }
- ]
- }
- ]
- }
- ]
- }
function krijgInfo(){
$.getJSON("gegevens.txt", function(result){
$.each(result.games[currentGame - 1].locaties[currentLocation - 1].items, function(){
$(".infolijst").append("<div data-role='collapsible'>");
$(".infolijst").append("<h3>"+ this.item + "</h3><p>"+ this.info +"</p>");
$(".infolijst").append("</div>");
});
$(".infolijst, $.mobile.activePage").collapsible({refresh: true});
});
};
- Hi,I'm working on a project for school with jQuery mobile and phonegap but when I want to load list elements into my unordered list it won't take over the liststyle. When I put list elements in before loading it works.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100%; width:100%; }
</style>
<link rel="stylesheet" href="gpsapp.css">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile.structure-1.0rc2.min.css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap-1.2.0.js"></script>
<script type="text/javascript" charset="utf-8">
function initialize(){//loader();
krijgGegevens();
}
function krijgGegevens(){
$.getJSON("gegevens.txt",function(result){
// $("#divjson").append("Game: " +result.games[1].game + " <br />Locatie: " + result.games[1].locaties[0].locatie + " <br /> Item: " + result.games[1].items[0].item + " <br /> Informatie: " + result.games[1].info );
// Get all the games
$.each(result.games, function(){
$("#gamelijst").append("<li><a href='index.html?id=" + this.id + "'>"+ this.game + "</a></li><br />");
});
});
}
</script>
</head>
<body onload="initialize();">
<div data-role="header" data-position="inline">
<h1>GPS Applicatie</h1>
</div>
<div class="ui-body ui-body-a">
<ul id="gamelijst" data-role="listview" data-theme="a">
</ul>
</div>
</body>
</html>
- «Prev
- Next »
Moderate user : bartjeeuhh
© 2013 jQuery Foundation
Sponsored by and others.

