JSON.parse vs. eval()
My Spider Sense warns me that using eval() to parse incoming JSON is a bad idea. I'm just wondering if JSON.parse() - which I assume is a part of JavaScript and not a browser-specific function - is more secure. ...
My Spider Sense warns me that using eval() to parse incoming JSON is a bad idea. I'm just wondering if JSON.parse() - which I assume is a part of JavaScript and not a browser-specific function - is more secure. ...
I have developed a native client interface which calls struts2 JSON RPC using post method. I have set content type, content length as suggested in the spec. The request body looks like as follows : {"method": "uploadTxpAssignment","id": "txpUploadRequest", "params":{"addressByDestAddrId":{"addrLine1":"test home","addrLine2":"7th ave","...
Can jQuery provide a fallback for failed AJAX calls? This is my try: function update() { var requestOK = false; $.getJSON(url, function(){ alert('request successful'); requestOK = true; }); if (!requestOK) { alert('request failed'); } } Unfortunately, even if the callback function of the $...
hi all I want build a 3statetree with checkbox,I had got the resource from cookbook,but I don't know how to use it with json, and how can i click one node then send the request to server and expand the subnode after receive the json data from server. thank you,thank you. ...
iam making a json object by the following query $arr = array(); $qs=qq("select main_cat_id,main_cat_name,id,name,cat_id,cat_id_main from main,scheme where main_cat_name='xyz' and cat_id_main=main_cat_id"); while($obj = mysql_fetch_object($qs)) { $arr[] = $obj; } $total=sizeof($arr)...
Hello, I'm trying to grab data from a JSON on an external site but the site doesn't support JSON-P output. This is an example of non-working code, but gives a good idea of what I'm trying to achieve: $.getJSON("http://www.bom.gov.au/fwo/IDV60901/IDV60901.94868.json", function(data){ //Process data here }); Are there ways around t...
I have the following ajax request: jQuery.ajax({ async: true, type: "GET", url: url, data: data, dataType: "json", success: function(results){ currentData = results; }, error: function(xhr, ajaxOptions, thrownError){ if (xhr.status == 200) { console.debug("Error code 200"); } else { cu...
My question is: can we use dojo.xhrPost to post some Json data? More detail: I have been experimenting with Dojo code to POST JSON data to a RESTful service. It seems to be that the behaviours of dojo.xhrPost and dojo.rawXhrPost are different, or to be more accurate rawXhrPost() works and xhrPost() does not. This is not consistent with ...
For a strange reason that does not matter for this question I need to create a JSON compatible substring that represents a DateTime and that will be manually insterted into a larger JSON string that later will be parsed by .NET's DataContractJsonSerializer. I have come up with the following method: static readonly DataContractJsonSerial...
I am not too savvy with JSON so any help would be great... I am loading a page via JQuery's .load. I am setting varname as a variable, but it is posting as the actual variable name not what I set it to. In other words it is showing up as "varname" instead of "class_id". var varname = "class_id"; $(this).siblings(".container").load(l...
Consider the following JSON: { "Code": 2, "Body": { "Dynamic-Key": { "Key1": "Val1", "Key2": "Val2" } } } Defining the following classes structure: [DataContract] class JsonResponse { [DataMember] public string Code { get; set; } [DataMember] public JsonResponseBo...
I'm using a book API that returns the following var _OLBookInfo = { "ISBN:234234234234234": { "bib_key": "ISBN:234234234234234", "preview": "noview", "preview_url": "http://openlibrary.org/b/adsfasdfa", "info_url": "http://openlibrary.org/b/adsfasdf", "details": { "publishers":...
I know there are a lot of sources which explain this, but they just talk about storing key/value pairs in an array or in an object. I can't understand why or when should I do this, although I always use jquery's AJAX. As an example, if I make a forum when do I need this? Can someone give real world examples? The same goes for XML. It s...
I want to make an Http request and store the result in a JSONObject. I haven't worked much with servlets, so I am unsure as to whether I am 1) Making the request properly, and 2) supposed to create the JSONObject. I have imported the JSONObject and JSONArray classes, but I don't know where I ought to use them. Here's what I have: ...
i dont understand one thing. if i want to get JSON data (key-value-pairs) from php to jquery using ajax...which of these following ones should i use? $.get $.post $.getJSON do i need to use getJSON if i want to use json_encode in php file? but what if i want to send with post? (there is no postJSON)? and one more thing: in php fil...
i use $.getJSON to call php file. it echos this back. for($i=0; $i<=10; $i++) { $nr[] = $i; } echo "{'result': 'error', 'count': '$nr'}"; in jquery to get result i just use alert(data.result) how do i get all the nr:s in count? EDIT: But how do i loop the array through in jquery? All the keys are numeric and i dont know how to...
i use $.getJSON and here is my php file echo:ing back jsonstring for($i=1; $i<=10; $i++) { $nr[] = "nr" . $i; } $nr = json_encode($nr); echo "{'result': 'error', 'count': '$nr'}"; how do i loop all the nr through with jquery html()? i want to echo it back to webpage like: nr 1 nr 2 nr 3 nr 4 nr 5 nr 6 nr 7 nr 8 nr 9 nr 10 ...
The objective is to have a form reflect user's defined constraints on a search. At first, I relied entirely upon server-side scripting to achieve this; recently I tried to shift the functionality to JavaScript. On the server side, the search parameters are stored in a ColdFusion struct which makes it particularly convenient to have t...
i use json_encode to send back data from php to jquery through ajax. and i have noticed that jquery just allow us to use ONE echo in php. if i use echo json_encode($array);.... and then one more echo json_encode($array2); in the same php file, then it would not work. or if i use echo json_encode($array); and then another echo "hello";...
I have cascading drop down lists in a .net mvc view and am using JQuery onchange to pull the next drop down list using a json response. The problem comes in where iI get a circular reference when trying to serialize the linq to sql response. I understand why it is happening, its because I have the buyer -> contracts and contract -> b...