Jump to content

Search the Community

Showing results for tags 'json'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

  1. Hi All, So I am having some trouble implementing Java/JSON onto my WordPress site. However, being self taught in HTML I am not as knowledgeable as this community, and W3schools is always my go to site. I have been given some brief instructions and 'codes/scripts' that will allow me to show an automatic feed from my partner. However, I cannot seem to get my head around how it is done. The instructions say to add some code to the header of the page, but when this is done and the rest of the instructions followed (to the best of my knowledge) there is nothing displayed. I have spent countless hours trying to figure out how to implement this Java/JSON this onto my site with no success. I have even contacted an online 'developer' who seemed to just go around in circles and not help in any way. He suggested adding the JSON Content Importer plugin and upgrading to the Pro version. This still didn't help in any way. Im sure that there is something very simple and easy missing from the equation, but I just cannot seem to get anywhere with this. I can provide any information and screenshots to anyone willing to help.
  2. Hi ! On of the tutorial pages https://www.w3schools.com/js/js_json_html.asp is missing code of php file. As I understand the code should be the same as on previous page of chapter, like: <?php $myObj->name = "John"; $myObj->age = 30; $myObj->city = "New York"; $myJSON = json_encode($myObj); echo $myJSON; ?> Sincerely, Alejandro.
  3. Attention: W3Schools.com forum members: The following ".json" data file is used in conjunction with an AJAX ( Asynchronous Javascript And XML ) file to print a Bible verse to my web page: {"book": "Deuteronomy", "chapter": "4", "verse": "<p><sup><b>20</b></sup>&#8202But the L<font size="2">ORD</font> has taken you and <sup><i>c</i></sup>&#8202brought you out of the iron furnace,<br> out of &#8201Egypt, <sup><i>d</i></sup>&#8202to be a people of his own inheritance, as you are this day.</p>"} The string "L<font size='2'>ORD</font>" prevents my ".json" data file from being printed to my web page. Why are the other hypertext markup language ( HTML ) tags accepted, but not the "<font></font>" HTML tag? Is there a solution for this problem? Thank you ( see Colossians 3:15, for example ) for your help and your patience. 🙂 Keep in touch. Sincerely in Christ, Russell E. Willis P.S. - Please read Proverbs 23:23.
  4. I have 3 files: html that is displaying data from json file using AngularJS, json file containing the data, script.js that stores the scripts. HTML file also has a form, from which I want to add data to my json file (onsubmit="insertData()"). insertData function is going to be in script.js I know, I may use .push method for this, but I don't know how to apply to the json file in this case. script.js var prg = angular.module('ajsprogram', []); prg.controller("outercont", function($scope, $http) { //function to display json file information $http.get('airlines.json').success(function(data){ $scope.info = data; $scope.airlineorder = 'airline'; }); }); function newairline(an,hb,ur,cs){ //new function to insert a data } airlines.json [ { "airline" : "British Airways", "hub" : "LHR", "url" : "http://britishairways.com", "callsign":"SPEEDBIRD" }, { "airline" : "Air France", "hub" : "CDG", "url" : "http://airfrance.com", "callsign":"AIRFRANS" }, { "airline" : "Virgin Atlantic", "hub" : "LGW", "url" : "http://virginatlantic.com", "callsign":"VIRGIN" }, { "airline" : "RyanAir", "hub" : "DUB", "url" : "http://ryanair.com", "callsign":"RYANAIR" }, { "airline" : "Emirates", "hub" : "DXB", "url" : "http://emirates.com", "callsign":"EMIRATES" } ]
  5. DILEMMA: I have a fairly complex JSON object that is introduced via an AJAX call. Unfortunately, my control panel tells me that it is undefined. Is this because it has no value? Or, is it because I do not know how to read the value properly? {"lastVisits"[{"firstVisit":{"prettyDate":"Monday, May 14, 2018"}}]} The name of the variable into which it is read is visitor_data. Am I reading the value of correctly? visitor_data.lastVisits[0].firstVisit.prettyDate Roddy
  6. I've built a static site with over 40,000 pages using Jekyll. I am trying to implement a live search into it without a database. I tried the w3schools live search example with a xml file I created from my site. It is very slow. Does anyone know of a faster way to parse xml files or am I wasting time. I enabled gzip compression on the entire site also, What would be the fastest way to search a lot of records and return a result? Thanks in advance.
  7. Hi, I've read the json tutorial on w3 website, and just have one question which makes a huge difference in the way I create the layout of my json file. All the examples they gave had a very short json file to read, but how does a json file look when you're trying to read many records. Does each httpRequest read the whole file from one first '{' to the last '}' and that's it. Or, if there are several, {'s will it return each one as an object. It was unclear to me from the tutorials. Specifically, If I had a database with 10 records and 5 fields in each, would I do this: { "name1" : "value1", "name2" : "value2", "name3" : "value3", "name4" : "value4", "name5" : "value5" } { "name1" : "value1", "name2" : "value2", "name3" : "value3", "name4" : "value4", "name5" : "value5" } { "name1" : "value1", "name2" : "value2", "name3" : "value3", "name4" : "value4", "name5" : "value5" }..... etc for 10 times, or would I do this with a name for my 'database' and make an array of the records: { databaseName [ { "name1" : "value1", "name2" : "value2", "name3" : "value3", "name4" : "value4", "name5" : "value5" } { "name1" : "value1", "name2" : "value2", "name3" : "value3", "name4" : "value4", "name5" : "value5" } { "name1" : "value1", "name2" : "value2", "name3" : "value3", "name4" : "value4", "name5" : "value5" } { "name1" : "value1", "name2" : "value2", "name3" : "value3", "name4" : "value4", "name5" : "value5" } .......etc to 10 records as an array ] } I think I'm understanding it as the second example - is this correct or am I missing something? Would it be all right to put 500 records in an array? I don't know how often they update the w3 website, but maybe they could emphasize this better. I know they went into creating the json file from a database using php and some other methods, but I want to create it myself and then upload the file to the server. One other question is that in the tutorial it said a json file has a json file type, but then they used a file in the example with a .txt type. I know json files are text files; but can you use .txt on your json file?
  8. function loadDoc(n_file) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var myObj = JSON.parse(this.responseText); var parametr = "september" var neco = myObj.september.17[0].dayname; var neco2 = "myObj." + parametr + ".17[0].dayname"; debugger; x = zacinajiciDen(neco); than i have this in my variables: neco1: "pa" neco2: "myObj.september17[0].dayname" i would like to have value "pa" inside like in neco1 but i would like to be able to change name of month. Is it possible Hi all, I have a simple problem. I would like to have a value of Object "myObj.september17[0].dayname" in my variable neco2. but there is of course more month which i need access and i need to changing this variable but when i use "myObj." + parametr + "17[0].dayname"; it is saved a string to variable instead of value. I am very new in JS, learning two days now so please be patient with me.
  9. Dear W3Schools-Community, There is something not working with my code right here. It should be mentioned that I am fairly new to using JavaScript. Here is my HTML code (stripped down to the essential parts): <!DOCTYPE html> <html lang="de"> <head> <script type="text/javascript"> function change_content(contentname) { if (document.getElementById(contentname).className = 'notactive') { document.getElementById('login').className = 'notactive'; document.getElementById('news').className = 'notactive'; document.getElementById('info').className = 'notactive'; document.getElementById('websites').className = 'notactive'; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById('content').innerHTML = this.responseText; if (contentname == 'kontakt' || contentname == 'hilfe' || contentname == 'impressum') { document.getElementById('info').className = 'active'; } else { document.getElementById(contentname).className = 'active'; } } }; xmlhttp.open('POST', contentname + 'page.php', true); xmlhttp.send(); } if (document.getElementById('info').className == 'active') { document.getElementById('dropdown-icon').src = "/ressource/images/nydoo-dropdown-icon-black.png"; } else { document.getElementById('dropdown-icon').src = "/ressource/images/nydoo-dropdown-icon-yellow.png"; } } window.onload = change_content; </script> </head> <header> <ul id="mainnavigation"> <li id="mainlist" class="dropdown"><a id="info" class="notactive" onclick="change_content(this.id);">Information<img id="dropdown-icon" style="width: 15px; height: 12px; float: right; margin-top: 7px; margin-right: 20px;" src="/ressource/images/nydoo-dropdown-icon-yellow.png" id="dropdown_icon"></a></li> </ul> </header> <body onload="change_content('login'); return false;"> <div id="content"> </div> </body> </html> What I'm trying to do is changing the color from img (id="dropdown-icon") from yellow to black whenever a (id="info") has class "active". Also the other way around (class "notactive" -> change from black to yellow). Hopefully this describes it. It maybe a simple thing. But I'm getting frustrated with this issue. Let me know if I screwed it up myself :3 Thank you very much n advance.
  10. Hello, I want to do a countdown and put it in my website. I did a countdown but I have a problem, when I launch it, the seconds are freezing they are not anymore running... So the countdown is not in realtime anymore... I have to refresh in order to see the countdown running. Here is what I did: <div id="after"> <span id="dhour"></span>:<span id="dmin"></span>:<span id="dsec"></span> </div> <div id="count2">Texte à afficher</div> <div class="numbers" id="dday" hidden="true"></div> <script> var ladate = new Date("<?php echo gmdate("Y-m-d\TH:i:s\Z");?>"); var year=ladate.getFullYear(); var month=ladate.getMonth()+1; var day=ladate.getDate(); var hour=14; var minute=20; var tz=0; var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); function countdown(yr,m,d,hr,min){ theyear=yr;themonth=m;theday=d;thehour=hr;theminute=min; var today= new Date("<?php echo gmdate("Y-m-d\TH:i:s\Z");?>"); var todayy=today.getYear(); if (todayy < 1000) {todayy+=1900; } var todaym=today.getMonth(); var todayd=today.getDate(); var todayh=today.getHours(); var todaymin=today.getMinutes(); var todaysec=today.getSeconds(); var todaystring1=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec; var todaystring=Date.parse(todaystring1)+(tz*1000*60*60); var futurestring1=(montharray[m-1]+" "+d+", "+yr+" "+hr+":"+min); var futurestring=Date.parse(futurestring1)-(today.getTimezoneOffset()*(1000*60)); var dd=futurestring-todaystring; var dday=Math.floor(dd/(60*60*1000*24)*1); var dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1); var dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1); var dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1); if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=0){ document.getElementById('count2').style.display="inline"; document.getElementById('after').style.display="none"; document.getElementById('dday').style.display="none"; document.getElementById('dhour').style.display="none"; document.getElementById('dmin').style.display="none"; document.getElementById('dsec').style.display="none"; document.getElementById('days').style.display="none"; document.getElementById('hours').style.display="none"; document.getElementById('minutes').style.display="none"; document.getElementById('seconds').style.display="none"; return;}else { document.getElementById('count2').style.display="none"; document.getElementById('dday').innerHTML=dday; document.getElementById('dhour').innerHTML=dhour; document.getElementById('dmin').innerHTML=dmin; document.getElementById('dsec').innerHTML=dsec; window.location.reload(); setTimeout("countdown(theyear,themonth,theday,thehour,theminute)",1000);}} countdown(year,month,day,hour,minute); </script> Thank you.
  11. consider this is my json array [ {"products":[{"productname":"Online Test","product":[{"subjectname":"Quants","lessonid":"16","subjectid":null,"subject_covered":"Algebra for SSC","lesson":"15","videoflag":false,"videos":null,"quiz":[{"practice":[{"title":"15.0 - Test of Quantitative Aptitude: Algebra for SSC : Lesson 15.0 ","nid":"21712","quizid":null}],"combo":null,"mock":null}],"ebook":null},{"subjectname":"Quants","lessonid":"17","subjectid":null,"subject_covered":"Trigonometry for SSC","lesson":"16","videoflag":false,"videos":[],"quiz":[{"practice":[{"title":"16.0- Test of Quantitative Aptitude: Trigonometry for SSC : Lesson 16.0 ","nid":"21816","quizid":null}],"combo":[],"mock":[]}],"ebook":null},{"subjectname":"Quants","lessonid":"18","subjectid":null,"subject_covered":"Mensuration for SSC","lesson":"17","videoflag":false,"videos":[],"quiz":[{"practice":[{"title":"17.0- Test of Quantitative Aptitude: Mensuration for SSC : Lesson 17.0 ","nid":"21675","quizid":null}],"combo":[],"mock":[]}],"ebook":null},{"subjectname":"Quants","lessonid":"19","subjectid":null,"subject_covered":"Geometry for SSC","lesson":"18","videoflag":false,"videos":[],"quiz":[{"practice":[{"title":"18.0 -Test of Quantitative Aptitude: Geometry for SSC : Lesson 18.0 ","nid":"21740","quizid":null}],"combo":[],"mock":[]}],"ebook":null},{"subjectname":"GK","lessonid":"02","subjectid":null,"subject_covered":"Test of SSC GK Question","lesson":"2","videoflag":false,"videos":[] and i want to print the product array and print the subject name as well as quiz array title in a web page... how to parse the json and display these results in html page? please help me thanks in advance
  12. Hi, I'm trying to follow the JSON example at http://www.w3schools.com/json/json_example.asp I have adjusted the code a little but the code is as follows: jsonTest.html <!DOCTYPE html> <html> <head> <style> h1 { border-bottom: 3px solid #cc9900; color: #996600; font-size: 30px; } table, th , td { border: 1px solid grey; border-collapse: collapse; padding: 5px; } table tr:nth-child(odd) { background-color: #f1f1f1; } table tr:nth-child(even) { background-color: #ffffff; } </style> </head> <body> <h1>Customers</h1> <div id="id01"></div> <script> var xmlhttp = new XMLHttpRequest(); var url = 'jsonTestPHP.php'; xmlhttp.onreadystatechange=function() { if (this.readyState == 4 && this.status == 200) { myFunction(this.responseText); } } xmlhttp.open("GET", url, true); xmlhttp.send(); function myFunction(response) { var arr = JSON.parse(response); var i; var out = "<table>"; for(i = 0; i < arr.length; i++) { out += "<tr><td>" + arr.Name + "</td><td>" + arr.Bedrooms + "</td><td>" + arr.Length + "</td></tr>"; } out += "</table>"; document.getElementById("id01").innerHTML = out; } </script> </body> </html> jsonTest.php <?php header("Access-Control-Allow-Origin: *"); header("Content-Type: application/json; charset=UTF-8"); require_once 'login.php'; $conn = new mysqli($hn, $un, $pw, $db); if ($conn->connect_error) die($conn->connect_error); $result = $conn->query("SELECT name, bedrooms, length FROM holidyhomes"); $outp = "["; while($rs = $result->fetch_array(MYSQLI_ASSOC)) { if ($outp != "[") {$outp .= ",";} $outp .= '{"Name":"' . $rs["name"] . '",'; $outp .= '"Bedrooms":"' . $rs["bedrooms"] . '",'; $outp .= '"Length":"'. $rs["length"] . '"}'; } $outp .="]"; $conn->close(); echo($outp); ?> So I have changed the var url = "http://www.w3schools.com/website/customers_mysql.php"; from the jsonTest.html to var url = 'jsonTestPHP.php'; When I run this I get "Invalid character: var arr = JSON.parse(response);" I just want to be able to grab the data from my database and display it on screen using JSON. Can anyone help me understand why I'm getting this Invalid character error or tell me if I'm going about this the totally wrong way? Thanks
  13. Hello All, I am stuck trying to filter results of a json response. I have a sample json response: [ { "id":0, "commentText":"Test", "createdBy":"User1", "isImportant":false }, { "id":1, "commentText":"Hello World", "createdBy":"User2", "isImportant":true }, { "id":2, "commentText":"Testing", "createdBy":"User2", "isImportant":false }, { "id":3, "commentText":"This is another one", "createdBy":"User2", "isImportant":true }, { "id":4, "commentText":"Hello World!", "createdBy":"User2", "isImportant":true } ] I am attempting to filter out results that "isImportant" are not true. I have tried multiple ways of doing it with no luck. IE. var response = $(jsonSample).filter(function (i,n){ return n.isImportant===true }); var response2 = $.grep(Object(jsonSample), function(j){ return j.isImportant !== false; }); var response3 = $.map(jsonSample, function (n,i){ $.each(n, function(j){ return n.isImportant !== false; }) }); console.log(response); //jquery-2.2.4.min.js:2 Uncaught Error: Syntax error, unrecognized expression: ... console.log(response2); //logs every individual character in the jsonSample ["[", "{", """, "i", "d", """, ":", "1", ... console.log(response3); //jquery-2.2.4.min.js:2 Uncaught TypeError: Cannot use 'in' operator to search for 'length' in ...
  14. I made an ajax call in my project, the call return a json object, i can see the json object in my console but when ever i call the w3DisplayDate() I get this error in my console " w3data.js:30 Uncaught TypeError: Cannot read property 'insertBefore' of null ". Is this a bug or am I doing something wrong, someone please help.
  15. im trying to output a json file to an expandable tree using html and jquery. its working, but the nesting and nodes within the tree are misplaced. any idea what that is? for example. mainstation 2 is coming out as a child of mainstation 1, while they should be siblings. it should be a logic error html code:<!DOCTYPE html><html> <head> <meta charset="UTF-8" /> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $.ajax({ url: "converted39.json", dataType: 'json', success: function(tree) { traverse($('#treeView'), tree) $('#treeView li:has(li)').addClass("Max").click(function(e) { $(this).toggleClass("Max Min"); $(this).children("ul").toggle(); e.stopPropagation(); }) $("[href]").addClass("Blue").click(function(e){ $(this).toggleClass("Purple"); e.stopPropagation(); window.location.href = $(this).attr("href") }) $('#treeView li').click(function(g) { var mytree2 = $(this); mytree2.children('li').toggle(); g.stopPropagation(); }) } }) }); function traverse(node, o) { for (var i in o) { if(i == "__text" || i == "_href" ) continue; if (o !== null && typeof(o)=="object") { if(o.__text){ var ul = $("<ul>").appendTo(node) var node=$('<li>').appendTo(ul) if(o._href){ var n = $("<span>").appendTo(node) $(n).text(o.__text).attr("href", o._href) } else{ $(node).text(o.__text) } } } traverse(node,o); } else{ var ul = $("<ul>").appendTo(node) if(o.__text){ var li = $('<li>' + o._text + '</li>').appendTo(ul) if(o._href){ var n = $("<span>").appendTo(node) $(n).text(o.__text).attr("href", o._href) } }else{ $('<li>' + o + '</li>').appendTo(ul) } } } } </script> JSON CODE:{ "MAIN": { "MainStation": [ { "Substation": [ { "Control": "Control1n", "ControlExpandable": { "MiniControl": [ "MiniControl1", "MiniControl2" ], "__text": "Control2" }, "PushButton": { "__text": "PushButton1", "_attr": "successnDatffffffffffffffffffffffffffffffffffffffffffffffffffffffffe:17july" }, "_href": "http://google.com", "__text": " Substation1nnnnnnn" }, { "ControlExpandable": { "MiniControl": [ "MiniControl1", "MiniControl2" ], "__text": "Control1", "_attr": "Control1 woohoo" }, "Control": "Control2", "PushButton": "PushButton1", "__text": " Substation2nnnnnnn" }, { "Control": [ "Control1", "Control2", "Control3", "Control4" ], "__text": " Substation3nnnnnnnnn" }, { "PushButton": [ "PushButton1", "PushButton2" ], "__text": " Substation4nnnnn" } ], "__text": " Mainstation1nnnnnnnnn" }, { "Substation": [ { "Control": [ "Control1", "Control2" ], "PushButton": "PushButton1", "__text": " Substation1nnnnnnn" }, { "ControlExpandable": { "MiniControl": [ "MiniControl1", "MiniControl2" ], "__text": "Control1" }, "Control": "Control2", "PushButtonExpandable": { "MiniPushButton": [ "MiniPushButton1", "MiniPushButton2" ], "__text": "PushButton1" }, "__text": " Substation2nnnnnnn" } ], "__text": " Mainstation2nnnnn" } ], "ElectricStation": { "Substation": [ { "Control": [ "Control1", "Control2" ], "PushButton": "PushButton1", "__text": " Substation1nnnnnnn" }, { "ControlExpandable": { "MiniControl": [ "MiniControl1", "MiniControl2" ], "__text": "Control1" }, "Control": "Control2", "PushButtonExpandable": { "MiniPushButton": [ "MiniPushButton1", "MiniPushButton2" ], "__text": "PushButton1" }, "__text": " Substation2nnnnnnn" } ], "__text": " ElectricStation1nnnnn" }, "__text": " MAINnnnnnnn" }}
  16. Bootstrap sounds a bit like a finished optional program to use? also It seemed like when I first started seeing this page I have been learning from, that it is trying to "sell me" on the HTML5 as a good new and easier way to think of html code I wonder if this stuff has any merit? is it true? Is there any particular Web and computer code language *(scripting etc,) that are universal, or more functional for a different similar type? like for example I have read that someone wrote "there personal favorite scripting is" and similar quoted. Is there any that are not liked or favored by many, but are more sort of fundamentally necessary to and work very well, and will be around to stay? It seems like to me HTML, is the way things are done, also interactions with internet and computers happens with javascript. As I have researched more about how it all works, It seems there are database languages that are used as well, and of course web page layout - CSS, it seems like some of these must be more of a basic foundation? I would like to focus on the types of web coding that have stood the test of time? types of code that aren't going anywhere due to the nature of how they function is not likely to be outdated soon? some of the questions and comments are referring to, jSON, mySql, appML, PHP, jquery, CSS, bootsrap, html5, (html5 vs. HTML or XHTML), xml, are any of the things listed Proprietarily limited more-so than others? or do any of them duplicate function of another? all generally speaking, I am sure there are reasons for everything. but to cut down the cluster of things to learn? which is important, and if multitudes of things are important enough to learn. which order is best?
  17. Hello everyone!I need your help.I have this code: @BuildTreeView(treeView, IdCategoriaParente) @helper BuildTreeView(IEnumerable<dynamic> data, int catfiglia, int? idcategoriaparente = 1, int level = 0, string accumulatore = ""){ // // var selectRecord = ""; var nodes = data.Where(n => n.IdCategoriaParente == idcategoriaparente).OrderBy(n => n.Id); var separatore = ""; if (nodes.Any()) { if (nodes.First().IdCategoriaParente != null) { if (level > 0) { separatore = " >> "; } } if (level == 0) { /* @Html.DropDownList("Direction", new List<SelectListItem>{ new SelectListItem{ Text = "Home To School", Value = "0" }, new SelectListItem{ Text = "School To Home", Value = "1" }}, new { onchange = "getAlldata()" }) */ @Html.Raw("<select name="IdCategoriaParente" id="IdCategoriaParente">"); @Html.Raw("<option value="0">Nessuna</option>"); } foreach (var node in nodes) { if (node.Id == catfiglia) { selectRecord = "selected"; } //Funzioni.SelezionaSelect(node.Id, catfiglia) else { selectRecord = ""; } var fullText = accumulatore + separatore + node.NomeCategoria; @Html.Raw(string.Format("rn<option value="{0}" {2}>{1}</option>", node.Id, fullText, selectRecord)); @BuildTreeView(data, catfiglia, node.Id, level + 1, fullText); } if (level == 0) { @Html.Raw("rn</select>"); } } else { // @Html.Raw("<select name="IdCategoriaParente" id="IdCategoriaParente"><option value="0">Nessuna</option></select>"); }} It is working properly. The problem is that now, the result is printed on the screen with a select.I wish the result was made into a JSON format: {"...", "...", "...": ...}Can you help me?Thanks in advance
  18. Good day everyone, Do you have a Google Translate script, as much as possible a URL, that returns a JSON format? For example I pass this URL using an AJAX request: https://google-translate-api-domain.com/q=large〈=english&to=afrikaans maybe it will return: {"translation":"groot"} Thanks in advance! - Regicide Del Feroz
  19. I desperately need to get some simple data from a file into a table on a web page. I've been pointed to using JSON, but I'm not getting something(s) correct with implementation. I'm not sure what I'm doing wrong and I've spent hours on the task. I'm not a developer, but I can follow instructions. Any help will be greatly appreciated. Here is what I have set up: A simple web page. The code is pasted below. A simple JSON file (new.json). It is in the same path as the web page (C:xampphtdocsxamppaudit). The file's contents are pasted below. I'm running XAMPP as my server. Only Apache is turned on. I've placed a copy of jquery-1.11.2.min.js on my web server. I've tried placing the copy at both C:xampphtdocsxampp and C:xampphtdocsxamppaudit, but I have no idea if this is correct or not. I'll be very grateful for any assistance in getting the web page to return the contents of the new.json file into a table on the web page. Thanks in advance, Andrew PS. I do have a separate and related thread going here, but I started too advanced. Right now, I just need something simple. I'll work with the details in the other thread after I get a working import. web page code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /><title>JSON 3</title><style>table { border: 1px solid #666; width: 100%;}th { background: #f8f8f8; font-weight: bold; padding: 2px;}</style></head><body>Example from: <a href="http://jsfiddle.net/sEwM6/258/">http://jsfiddle.net/sEwM6/258/</a><br/><br/><table id="personDataTable"> <tr> <th>Id</th> <th>First Name</th> <th>Last Name</th> </tr></table><script>$.ajax({ url: 'new.json', //Change this path to your JSON file. type: "post", dataType: "json", success: function(data, textStatus, jqXHR) { drawTable(data); }});function drawTable(data) { var rows = []; for (var i = 0; i < data.length; i++) { rows.push(drawRow(data[i])); } $("#personDataTable").append(rows);}function drawRow(rowData) { var row = $("<tr />") row.append($("<td>" + rowData.id + "</td>")); row.append($("<td>" + rowData.firstName + "</td>")); row.append($("<td>" + rowData.lastName + "</td>")); return row;}</script></body></html> new.json data: {json: JSON.stringify([{id: 1,firstName: "Peter",lastName: "Jhons"},{id: 2,firstName: "David",lastName: "Bowie"}]}
  20. Ok, Hi everyone. I found this awesome and simplistic shopping cart on codepen.com BUT I do not know how to make it work .... :(TO begin with here is the link for it: http://codepen.io/bartveneman/details/KHxLGI am using Dreamweaver to make my website. So I copied it all, made sure that the links between my html, css and js are working fine and it still does not work. My problem with it is as follows: I did a copy+paste on it cannot shows me the cart without any items. I do not know how to add items without ruining the JS which will calculate things like total price, subtotal, etc. Things that I tried [ if you know exactly what I need to do don't bother reading what I tried, I am a beginner anyways ] I tried replacing inside the HTML the places where it says things like "src="{{=img}}" I would replace it the source with an actual source path for an image which works but shows nothing at all. I tried then also here in the HTMl file to simply take the tag off. As you see the html is based on one top part which is a big tag then is has the footer. The items are inside the tag at the top, BUT the tag is enclosed within some script tag so I removed the script and it shows one item ok-ish. The problem with this is that it would function with the script. For example it shows the item now but I cant add it to cart anything. Lastly, I looked inside the JS file and I found the section with the app variable which seems to have the details for the items included in the example. I changed those but nothing shows... So I tried some basic stuff. If anybody can help me with this by the end of the weekend it would be great !
  21. <?php$salename=json_encode($oSales);?> I need pass variable in php script to javaScript code in series <script type="text/javascript"> $(function () {$('#lineChartSales').highcharts({chart: {type: 'line'},title: {text: 'Monthly Average Sales'},xAxis: {categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']},yAxis: {title: {text: 'Temperature (°C)'}},plotOptions: {line: {dataLabels: {enabled: true},enableMouseTracking: true}},series: [{name:a,data: [1, 6.9, 9.5, 14.5, 18.4, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]},{name: b,data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]}]});});</script> Any help Thanks
  22. Hello, I have a php web page that contains graphics, and I want to incorporate into this web page a drop-down list, selecting the year, we display the graphic that matches this year at the same page ... I created the drop-down list in html but I know how to have when you click on an item in the drop-down list displays all my graphics in the same web page. here is the list that I created: <form name="test" method="post" action ="home.php"><select name="annee" onChange="this.form.submit()"> <option value="1"> 2009</option> <option value="2" >2010</option> <option value="3">2011</option> <option value="4">2012</option></select> Here is my graphics : <div class="col-lg-6"><div class="panel-body text-center"> <script type="text/javascript"> $(document).ready(function() { var options = { chart: { renderTo: 'container0', type: 'column', }, title: { text: 'Evolution trimestrielle du Parc Mobile ' }, xAxis: { categories: ['mars-08','juin-08','sept-08','déc-08','mars-09' ] }, yAxis: { min: 0, title: { text: 'millions' }, }, legend: { enabled: false }, plotOptions: { series: { dataLabels: { enabled: true, format: '{point.y:.1f}' }}}, tooltip: { pointFormat: ' <b>{point.y:.1f} millions</b>' }, series: [] } $.getJSON("evte.php", function(json){ //options.xAxis.categories=json[0]['data']; options.series[0]=json[0];chart=new Highcharts.Chart(options);}); });</script> <div id="container0" style="min-width: 400px; height: 400px; margin: 0 auto"> </div> </div></div> <div class="col-lg-6"><div class="panel-body text-center"> <script type="text/javascript">$(document).ready(function() { var options = { chart: { renderTo: 'container', type: 'column', }, title: { text: 'Répartition Prépayé Post-payé' }, xAxis: { categories: ['mars-08','juin-08','sept-08','déc-08','mars-09'] }, yAxis: { min: 0, title: { text: 'milliers' }, stackLabels: { enabled: true, style: { fontWeight: 'bold', color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray' } } }, legend: { align: 'center', x: 10, verticalAlign: 'under', y: 371, floating: true, backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white', borderColor: '#CCC', borderWidth: 1, shadow: false }, tooltip: { formatter: function () { return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + '<br/>' + 'Total: ' + this.point.stackTotal; } }, plotOptions: { column: { stacking: 'normal', dataLabels: { enabled: true, color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white', style: { textShadow: '0 0 3px black, 0 0 3px black' } } } }, series: [] } $.getJSON("repartition.php", function(json){ options.series[0]=json[0]; options.series[1]=json[1]; chart=new Highcharts.Chart(options);}); }); </script> <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"> </div> </div> </div> </div></div></div> <div class="tab-pane fade" id="service-two"> <br/> <div class="col-lg-6"><div class="panel-body text-center"> <script type="text/javascript"> $(document).ready(function() { var options = { chart: { renderTo: 'container09', type: 'column', }, title: { text: 'Evolution trimestrielle du Parc Mobile (en milliers)' }, xAxis: { categories: ['juin-08','sept-08', 'déc-08','mars-09','juin-09' ] }, yAxis: { min: 0, title: { text: 'millions' } }, legend: { enabled: false }, plotOptions: { series: { dataLabels: { enabled: true, format: '{point.y:.1f}' }}}, tooltip: { pointFormat: ' <b>{point.y:.1f} millions</b>' }, series: [] } $.getJSON("evtrimmobile juin09.php", function(json){ options.series[0]=json[0];chart=new Highcharts.Chart(options);}); }); </script> <div id="container09" style="min-width: 400px; height: 400px; margin: 0 auto"> </div> </div></div> <div class="col-lg-6"><div class="panel-body text-center"> <script type="text/javascript"> $(document).ready(function() { var options = { chart: { renderTo: 'containerr09', type: 'column', }, title: { text: 'Répartition Prépayé Post-payé' }, xAxis: { categories: ['juin-08','sept-08','déc-08','mars-09','juin-09'] }, yAxis: { min: 0, title: { text: 'milliers' }, stackLabels: { enabled: true, style: { fontWeight: 'bold', color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray' } } }, legend: { align: 'center', x: 10, verticalAlign: 'under', y: 371, floating: true, backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || 'white', borderColor: '#CCC', borderWidth: 1, shadow: false }, plotOptions: { series: { dataLabels: { enabled: true, format: '{point.y:.1f}' }}}, tooltip: { formatter: function () { return '<b>' + this.x + '</b><br/>' + this.series.name + ': ' + this.y + '<br/>' + 'Total: ' + this.point.stackTotal; } }, plotOptions: { column: { stacking: 'normal', dataLabels: { enabled: true, color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white', style: { textShadow: '0 0 3px black, 0 0 3px black' } } } }, series: [] } $.getJSON("repartitionm.php", function(json){ options.series[0]=json[0]; options.series[1]=json[1]; chart=new Highcharts.Chart(options);}); }); </script> <div id="containerr09" style="min-width: 400px; height: 400px; margin: 0 auto"> </div> </div></div> </div> PS: graphics are created using software Highcharts Thank you for helping me.
  23. Hi, I have this following code: http://jsfiddle.net/dustcomposer/bapwnhy0/ var cresc_path = '<path class="dyna_line" id="dyna_line" d="M ' + 0 + ' ' + 0 + ' L ' + 50 + ' ' + 25 + ' M ' + 0 + ' ' + 50 + ' L ' + 50 + ' ' + 25 + '" style="stroke-width: 1; stroke: red; fill:none;" />';var dl = document.createElementNS("http://www.w3.org/2000/svg", "svg");dl.setAttribute('class', 'dyHolder');dl.setAttribute('id', 'dyHolder');dl.setAttribute('style', 'border:1px solid red');dl.setAttribute('width', '50');dl.setAttribute('height', '50');dl.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");dl.innerHTML = cresc_path;document.getElementById('a').appendChild(dl);var str = '<svg class="dyHolder" id="dyHolder" style="border:1px solid red" width="50" height="50" xmlns:xlink="http://www.w3.org/1999/xlink"><path class="dyna_line" id="dyna_line" d="M 0 0 L 50 25 M 0 50 L 50 25" style="stroke-width: 1; stroke: red; fill:none;"></path></svg>';document.getElementById('b').innerHTML = str; both dl and str does result a svg image in html page. but when I grab similar string with str from json file, it appears as text like: <svg class="dyHolder" id="dyHolder" style="border:1px solid red" width="50" height="50" xmlns:xlink="http://www.w3.org/1999/xlink"><path class="dyna_line" id="dyna_line" d="M 0 0 L 50 25 M 0 50 L 50 25" style="stroke-width: 1; stroke: black; fill:none;"></path></svg> can anyone explain what the problem is? UPDATE: I've found the problem! the saved json structure must be typed neat. If the json structure made like this: [[ "28/11/2014 - 7:7", "", "", ""],[ "", "", "", ""],["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],["", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "<svg class="dyHolder" id="dyHolder" style="border:none" width="140" height="10" xmlns:xlink="http://www.w3.org/1999/xlink"><path class="dyna_line" id="dyna_line" d="M 0 0 L 140 5 M 0 10 L 140 5" stroke-width="1" stroke="black" fill="none"></path></svg>"]] the svg (as string) won't appears as svg but a paragraph/text. therefore it should written like this: [[ "28/11/2014 - 7:7", "", "", ""],[ "", "", "", ""],[ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],[ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],[ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""],[ "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "<svg class="dyHolder" id="dyHolder" style="border:none" width="140" height="10" xmlns:xlink="http://www.w3.org/1999/xlink"><path class="dyna_line" id="dyna_line" d="M 0 0 L 140 5 M 0 10 L 140 5" stroke-width="1" stroke="black" fill="none"></path></svg>"]] Everything works well now.
  24. Hi to all, i hope to find some help here. This is my problem, which need urgent help. Im working on a chrome extension, VERY VERY basic. My extension block a list of "urls" so i have 2 files for my chrome extension, my manifest.json and background.js Code of manifest.json: {"name":"Stop-it","description":"app","version":"1.0,"manifest_version":2,"permissions": ["webRequest","webRequestBlocking","unlimitedStorage"],"icons":{"48":"icon.png"},"background":{"scripts": ["background.js"]},"browser_action":{"default_popup":"popup.html","default_icon":"icon.png"}} and the code of my background.js: chrome.webRequest.onBeforeRequest.addListener( function(details) {return {cancel: true};}, { urls:[ .url1, .url2, etc... ] },['blocking']); at the moment i store all the urls, inside the background.js, and thats the problem, because its a list of urls i update every week, and my urls list has 2 millions urls, so when i install my extension, and start browsing, chrome become really really slower. I really need help on this problem, the manifest.json, is perfect and work perfectly, the problem come from my background.js, how to store all those urls on the user computer, instead of the background.js, i add here a jpeg file who show the memory consumption in chrome. thanks to all
  25. I have been trying to develop my google places map. I found this page, https://developers.g...on/autocomplete which is what I think I want. I want to be able to search a specific word and return only results that I input. I am not sure how to link the JSON script to the XML. I need some help.
×
×
  • Create New...