Search Results

Search found 5856 results on 235 pages for 'json encode'.

Page 25/235 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • jquery - access json data from php

    - by Cinaird
    I have a problem accessing JSON data. I'm new to JSON an jquery so there is probably a easy solution to it and i would be glad to find out. My jQuery: $.post( "currentPage.php", { 'currentPage': 1 }, function(data){ $("body").append(data); } ); currentPage.php: $returnArray['left'] = 'test_left'; $returnArray['right'] = 'test_right'; $returnArray['numLeft'][] = 1; $returnArray['numRight'][] = 2; $returnArray['numRight'][] = 3; print json_encode($returnArray); i tried to access the data like this: data.left data['left'] but it returns blank, how is the best way to access the data?

    Read the article

  • remove json attribute where attribute is a variable

    - by pedalpete
    I have a news feed where items in the feed are created from JSON returned from a server. When the user takes an action on an item, I want to remove it from the object via javascript. The feed looks like this: {"newsFeed":[{"feedId":"1", "title":"item1 title", "desc":"description of the item"}, {"feedId":"2", "title":"item2 title", "desc":"description of the item"}]} I'm trying to remove a JSON attribute or entry where the feedId is passed in via a variable using jQuery. I'm not sure exactly where I'm going wrong here, but when I alert the feed before and after the removal of the object, I'm getting the same response: function removeFromFeed(feedId){ var newsFeed=jQuery('div#newsFeed').data('newsFeed'); alert(newsFeed.toSource()); delete newsFeed.feedId[feedId] jQuery('div#newsFeed').data('newsFeed',newsFeed); alert(newsFeed.toSource()); }

    Read the article

  • jQuery and CodeIgniter AJAX with JSON not working

    - by thedp
    Hello, I trying to make my first AJAX with JSON call using jQuery and CodeIgniter. But for some weird reason it's not working. The jQuery code: var item = "COOL!"; $.post("http://192.168.8.138/index.php/main/test", { "item" : item }, function(data){ alert(data.result); }, "json"); The CodeIgniter code: <?php class main extends Controller { function test() { $item = trim($this->input->post('item')); $array = array('result' => $item); echo json_encode($array); } } ?> I tried to access the http://192.168.8.138/index.php/main/test page manually and it seems to be working, I got: {"result":""} I also tried to use Firebug to see XMLHttpRequest but saw nothing. I have no idea what am I doing wrong... Need help really badly. Thank you.

    Read the article

  • mySql table returning JSON that needs formatting for a iPhone UITableview

    - by Michael Robinson
    I have a php query the returns the following JSON format from a table. [{"memberid":"18", "useridFK":"30", "loginName":"Johnson", "name":"Frank", "age":"23", "place":"School", }, It needs the following format: [{"memberid":"18" { "useridFK":"30", "loginName":"Johnson", "name":"Frank", "age":"23", "place":"School",} }, I can figure out where/how to convert this, Where would I create the formatting following: (1) In the php return? (2) the JSON instructions for deserialization? or (3) Some kinb of Obj-C coding instruction? My end use is a simple Drill Down table using the NSObject, so when I select "memberid" row, I'll get the child/detail list on the next UITableview. My Data.plist will look like the following: Root: Dictionary V Rows: Array V Item 0: Dictionary Title: String 18 V Children Array V Item 0 Dictionary Title String 30 etc. Thanks in advance, this site rocks.

    Read the article

  • JSON in an AJAX request

    - by Josh K
    I have a PHP API I'm working with that outputs everything as JSON. I need to call one of the API methods and parse it out using an AJAX request. I am using jQuery (though it shouldn't matter). When I make the request it errors out with a "parsererror" as the textStatus and a "Syntax Error: invalid label" when I make the request. Simplified code: $.ajax ({ type: "POST", url: "http://mydomain.com/api/get/userlist/"+mid, dataType: "json", dataFilter: function(data, type) { /* Here we assume and pray */ users = eval(data); alert(users[1].id); }, success: function(data, textStatus, XMLHttpRequest) { alert(data.length); // Should be an array, yet is undefined. }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(textStatus); alert(errorThrown); }, complete: function(XMLHttpRequest, textStatus) { alert("Done"); } });

    Read the article

  • asp.net mvc json open dialog box problem

    - by mazhar kaunain baig
    function postForm() { $.ajax({ type: "POST", data: $("#myForm").serialize(), dataType: "json", url: '<%= Url.Action("JSONRequest","Home") %>', success: function(result) { window.alert(result.name); }, error : function() { window.alert('error'); } }); } Html.BeginForm("JSONRequest", "Home", FormMethod.Post, new { id = "myForm" }); Html.TextBox("mazhar") <input type="submit" onclick="postForm" /> Html.EndForm(); public ActionResult JSONRequest(FormCollection form) { string a = form["mazhar"]; var data = new { name = "aaaa", Success = "Record is Succesfully Saved", ErrorMessages = "abc" }; return Json(data); } Ok the problem is that the dialog box is opening after running this code which is asking to save file. Can someone tell me how to resolve this issue?

    Read the article

  • No exception, no error, still i dont recieve the json object from my http post

    - by user2978538
    My source code: final Thread t = new Thread() { public void run() { Looper.prepare(); HttpClient client = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); HttpResponse response; JSONObject obj = new JSONObject(); try { HttpPost post = new HttpPost("http://pc.dyndns-office.com/mobile.asp"); obj.put("Model", ReadIn1); obj.put("Product", ReadIn2); obj.put("Manufacturer", ReadIn3); obj.put("RELEASE", ReadIn4); obj.put("SERIAL", ReadIn5); obj.put("ID", ReadIn6); obj.put("ANDROID_ID", ReadIn7); obj.put("Language", ReadIn8); obj.put("BOARD", ReadIn9); obj.put("BOOTLOADER", ReadIn10); obj.put("BRAND", ReadIn11); obj.put("CPU_API", ReadIn12); obj.put("DISPLAY", ReadIn13); obj.put("FINGERPRINT", ReadIn14); obj.put("HARDWARE", ReadIn15); obj.put("UUID", ReadIn16); StringEntity se = new StringEntity(obj.toString()); se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json")); post.setEntity(se); post.setHeader("host", "http://pc.dyndns-office.com/mobile.asp"); response = client.execute(post); if (response != null) { InputStream in = response.getEntity().getContent(); } } catch (Exception e) { e.printStackTrace(); } Looper.loop(); } }; t.start(); } } i want to send an Json object to a Website. As far as I can see, I set the header, but still I get this exception, can someone help me? (I'm using Android-Studio) __ Edit: i don't get any exceptions anymore, but still i do not receive the json packet. When i manually call the website i get a log file entry. Does anyone know, what's wrong? Edit2: When i debug i get as response "HTTP/1.1 400 bad request" i'm sure its not an permission problem. Any ideas?

    Read the article

  • JSON Date coming through as Today's date?

    - by Liam
    I'm trying to convert a JSON date to a dd/mm/yyyy format, which I'm managing to do semi-successfully. The problem I'm encountering is that the date from the record in the DB is for example, 2009-06-29 which is returning the usual JSON /Date(1246230000000)/, however, when I try and turn it into the previously mention dd/mm/yyyy format, it's coming through as today's date. The code I'm using to try and do this is: $('input#EmployeeName').result(function(event, data, formatted) { $('#StartDate').html(formatJSONDate(Date(!data ? '' : data.StartDate))); }); function formatJSONDate(jsonDate) { var newDate = dateFormat(jsonDate, "dd/mm/yyyy"); return newDate; } I'm using JavaScript Date Format to try and run the function. Any help is greatly appreciated.

    Read the article

  • Using a variable as identifier in a json array

    - by Robbert van den Bogerd
    Hi folks! I'm wondering if it is possible to use assigned variables as identifier in a json array. When I tried this, I was getting some unexpected results: (Code is simplified, parameters are passed in a different way) var parameter = 'animal'; var value = 'pony'; Util.urlAppendParameters (url, {parameter : value}); Util.urlAppendParameters = function(url, parameters) { for (var x in parameters) { alert(x); } } Now the alert popup says: 'parameter' instead of 'animal'. I know I could use a different method (creating an array and assigning every parameter on a new line), but I want to keep my code compact. So my question is: Is it possible to use a variable as an identifier in the json array, and if so, could you please tell me how? Thanks in advance!

    Read the article

  • Best way to save complex Python data structures across program sessions (pickle, json, xml, database

    - by Malcolm
    Looking for advice on the best technique for saving complex Python data structures across program sessions. Here's a list of techniques I've come up with so far: pickle/cpickle json jsonpickle xml database (like SQLite) Pickle is the easiest and fastest technique, but my understanding is that there is no guarantee that pickle output will work across various versions of Python 2.x/3.x or across 32 and 64 bit implementations of Python. Json only works for simple data structures. Jsonpickle seems to correct this AND seems to be written to work across different versions of Python. Serializing to XML or to a database is possible, but represents extra effort since we would have to do the serialization ourselves manually. Thank you, Malcolm

    Read the article

  • XMLHttpRequest - JSON - .NET

    - by user318194
    I am trying to send JSON from my mozilla addon to my asp.net page. var myJSONObject = {"userName": una,"password": pass}; request = new XMLHttpRequest(); request.open("GET",http://www.google.com/jo=" + myJSONObject,true, null, null); on my .net page I have tried several ways of doing it but not able to find the best way to serialize and deserialize the code. All I need is to send the json data back n forth and parse it on C# n javascript. I am new to all this so any guidance and/or change in direction is appreciated.

    Read the article

  • image with json and iphone

    - by alecnash
    Hi, I've got some images saved inside a db in a server and want to use them for my iphone. I created a php file so I can access them with json, got some questions though. I save all the text data from the db to a nsdictonary and it works fine. For the images should I use nsdata? Should I write a new php file for getting the image or is one enough because I am using an array to store my objects and then I use json_encode($arr) for json. Is it ok to store data to an array or is everything gonna crash?

    Read the article

  • Populating fields, input types etc using JSON

    - by Franco
    I have a form that works as follows.. Server request builds XML of the data on server side and sends xml, XSL stylesheet then transforms the XML data into the plain html page distributing the data to the relevant/desired locations of the form on the page. Person can view page and edit the populated form, submit back to DB. I think JSON is more suitable for this from what I have read. The form itself is split into 3 areas, for me this is 3 maps/associative arrays etc each with a name related to the id of an input element etc. The problem for me comes with having the JSON sent to the page, what should I do with it next in order to achieve the same result as I currently get with XML and XSL. Thanks.

    Read the article

  • Google Maps integration with JSON - CircularReferenceError

    - by JZ
    I'm working on Rails 3.0.0.beta2, following Advanced Rails Recipes "Recipe #32, Mark locations on a Google Map" and I hit a road block. The following code is returning a "ActiveSupport::JSON::Encoding::CircularReferenceError" "object references itself" at line 3. This code represents the /layouts/maps.html.erb file <% if @maps -%> <script type="text/javascript"> var maps = <%= @maps.to_json %>; </script> <% end -%> This is my first attempt at rendering JSON, and I don't know how to debug this problem. Do you have experience with this? What could cause this problem? Thank you in advance!

    Read the article

  • ASP.NET MVC: Posting JSON to Controller

    - by JamesBrownIsDead
    I've got this in my controller: [HttpPost] public void UpdateLanguagePreference(string languageTag) { if (string.IsNullOrEmpty(languageTag)) { throw new ArgumentNullException("languageTag"); } ... } And have this jQuery code POSTing to the controller: jQuery.ajax({ type: 'POST', url: '/Config/UpdateLanguagePreference', contentType: 'application/json; charset=utf-8', data: '{ "languageTag": "' + selectedLanguage + '" }' }); When I try to the code, however, I get the error: Server Error in '/' Application. Value cannot be null. Parameter name: languageTag What's the problem? Isn't this how to POST JSON to an MVC Controller? I can examine the POST using Fiddler and see that the request is correct. For some reason, UpdateLanguagePreference() is getting a null or empty string.

    Read the article

  • json object composition details

    - by Ethan
    in .json text, is the 'value' in a basic single pair object the title of a value type (e.g. [string, number, object]), or a value for a typed object (e.g. 2, or "dog", or Object3)? This is how http://www.json.org/ presents the information: "An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma)."

    Read the article

  • Java Http request on api.stackexchange with json response

    - by taoder
    I'm trying to use the api-stackexchange with java but when I do the request and try to parse the response with a json parser I have an error. public ArrayList<Question> readJsonStream(InputStream in) throws IOException { JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8")); reader.setLenient(true); try { System.out.println(reader.nextString()); // ? special character return readItem(reader); } finally { reader.close(); } } public ArrayList<Question> readItem(JsonReader reader) throws IOException { ArrayList<Question> questions = new ArrayList<Question>(); reader.beginObject(); while (reader.hasNext()) { System.out.println("here");//not print the error is before String name = reader.nextName(); if (name.equals("items")) { questions = readQuestionsArray(reader); } } reader.endObject(); return questions; } public final static void main(String[] args) throws Exception { URIBuilder builder = new URIBuilder(); builder.setScheme("http").setHost("api.stackexchange.com").setPath("/2.0/search") .setParameter("site", "stackoverflow") .setParameter("intitle" ,"workaround") .setParameter("tagged","javascript"); URI uri = builder.build(); String surl = fixEncoding(uri.toString()+"&filter=!)QWRa9I-CAn0PqgUwq7)DVTM"); System.out.println(surl); Test t = new Test(); try { URL url = new URL(surl); t.readJsonStream(url.openStream()); } catch (IOException e) { e.printStackTrace(); } } And the error is: com.google.gson.stream.MalformedJsonException: Expected literal value at line 1 column 19 Here is an example of the Json : { "items": [ { "question_id": 10842231, "score": 0, "title": "How to push oath token to LocalStorage or LocalSession and listen to the Storage Event? (SoundCloud Php/JS bug workaround)", "tags": [ "javascript", "javascript-events", "local-storage", "soundcloud" ], "answers": [ { "question_id": 10842231, "answer_id": 10857488, "score": 0, "is_accepted": false } ], "link": "http://stackoverflow.com/questions/10842231/how-to-push-oath-token-to-localstorage-or-localsession-and-listen-to-the-storage", "is_answered": false },... So what's the problem? Is the Json really malformed? Or did I do something not right? Thanks, Anthony

    Read the article

  • JSON or YAML encoding in GWT/Java on both client and server

    - by KennethJ
    I'm looking for a super simple JSON or YAML library (not particularly bothered which one) written in Java, and can be used in both GWT on the client, and in its original Java form on the server. What I'm trying to do is this: I have my models, which are shared between the client and the server, and these are the primary source of data interchange. I want to design the web service in between to be as simple as possible, and decided to take the RESTful approach. My problem is that I know our application will grow substantially in the future, and writing all the getters, setters, serialization, factories, etc. by hand fills me with absolute dread. So in order to avoid it, I decided to implement annotations to keep track of attributes on the models. The reason I can't just serialize everything directly, using GWT's own one, or one which works through reflection, is because we need a certain amount of logic going on in the serialization process. I.e. whether references to other models get serialized during the serialization of the original model, or whether an ID is just passed, and general simple things like that. I've then written an annotation processor to preprocess my shared models and generate an implementing class with all the getters, setters, serialization, lazy-loading, etc. To make a long story short, I need some type of simple YAML or JSON library, which allows me to encode and decode manually, so I can generate this code through my annotation processor. I have had a look around the interwebs, but every single one I ran into supported some reflection which, while all fine and dandy, make it pretty much useless for GWT. And in the case of GWT's own JSON library, it uses JSNI for speed purposes, making it useless server side. One solution I did think about involved writing writing two sets of serialization methods on the models, one for the client and one for the server, but I'd rather not do that. Also, I'm pretty new to GWT, and even though I have done a lot of Java, it was back in the 1.2 days, so it's a bit rusty. So if you think I'm going about this problem completely the wrong way, I'm open to suggestions.

    Read the article

  • programmatically creating property list from json to include an array

    - by Michael Robinson
    [{"memberid":"18", "useridFK":"30", "loginName":"Johnson", "name":"Frank", "age":"23", "place":"School", },] Someone else posted a similar question but without the fact that it was coming from a JSON deserialization. Quinn had some suggestions but it was confused about where to place/replace the following code (if it's correct): NSDictionary *item1 = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@" member",[NSNumber numberWithInt:3],nil] forKeys:[NSArray arrayWithObjects:@"Title",@"View",nil]]; into this: NSData *jsonData = [jsonreturn dataUsingEncoding:NSUTF32BigEndianStringEncoding]; NSError *error = nil; NSDictionary * dict = [[CJSONDeserializer deserializer] deserializeAsDictionary:jsonData error:&error]; if (dict) { rowsArray = [dict objectForKey:@"member"]; [rowsArray retain]; } My Array.plist needs to look like the following: Root: Dictionary V Rows: Array V Item 0: Dictionary Title: String 18 V Children Array V Item 0 Dictionary Title String 30 etc. Thanks in advance. Every tutorial on JSON only shows a simple array being returned, never a 2-D..It's driving me crazy trying to figure this out.

    Read the article

  • Issue on passing a checkbox set to an AppEngine script through jQuery Ajax/Json

    - by Jorge
    I have a set of checkboxes with multiple choice allowed. I parse the set this way: if ($("input[name='route_day']:checked").length > 0) { $("input[name='route_day']:checked").each(function(){ if(this.value != null) route_days_hook.push(this.value); }); dataTrap.route_days = $.JSON.encode(route_days_hook); } ...and pull the whole dataTrap to an AppEngine Python script via jQuery ajax. However, the Python script just bugs. If i change dataTrap.route_days value to a string instead of the JSON encoded object, everything works fine. My question is: how can i pass a checkbox set to the script using Ajax and still be able to iterate over it on the script?

    Read the article

  • C / JSON Library in popular Linux distros?

    - by Tim Post
    I have a program written in C that has to input and output JSON over a local domain socket. I've found several C / JSON libraries that 'almost work' through searches. Prior to taking one of the libraries that I found .. I want to be sure that I'm not over-looking a library that is commonly found on modern Linux distros. I'd also really appreciate links to libraries that you use. Most likely, I'll just drop it in tree, unless I realize that I've over looked something widely distributed. I am tagging this as subjective because the answer that I select is the one linking to a library that works for me, that does not mean its the 'best' library. I want to take an existing array and easily convert it to a buffer that can be sent, or take a buffer and easily convert it into an allocated array. Thanks in advance!

    Read the article

  • Exception while trying to deserialize JSON into EntityFramework using JavaScriptSerializer

    - by Barak
    I'm trying to deserialize JSON which I'm getting from an external source into an Entity Framework entity class using the following code: var serializer = new JavaScriptSerializer(); IList<Feature> obj = serializer.Deserialize<IList<Feature>>(json); The following exception is thrown: Object of type 'System.Collections.Generic.List1[JustTime.Task]' cannot be converted to type 'System.Data.Objects.DataClasses.EntityCollection1[JustTime.Task]'. My model is simple: The Feature class has a one-to-many relation to the Tasks class. The problem appears to be the deserializer is trying to create a generic List to hold the collection of tasks instead of an EntityCollection. I've tried implementing a JavaScriptConverted which would handle System.Collections.Generic.List but it didn't get called by the deserializer.

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >