Search Results

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

Page 75/235 | < Previous Page | 71 72 73 74 75 76 77 78 79 80 81 82  | Next Page >

  • Python how to handle # in a dictionary

    - by Jack
    I've got some json from last.fm's api which I've serialised into a dictionary using simplejson. A quick example of the basic structure is below. { "artist": "similar": { "artist": { "name": "Blah", "image": {"#text":"URLHERE","size": "small"} "image": {"#text":"URLHERE","size": "medium"} "image": {"#text":"URLHERE","size": "large"} } } } Any ideas how I can access the image urls of various different sizes. My attempts at accessing the #text variable don't seem to work because python doesn't appear to like #'s in the names. And any ideas how I can easily get the url for the depending on the size? Thanks, Jack

    Read the article

  • json jquery post request

    - by John
    <script type="text/javascript"> $(document).ready(function() { $("a").click(function() { var content = $('#content').html(); var data = {"content":content}; $.ajax({ type: "POST", dataType: "json", url: "ajax.php", data: {content:content}, success function (data) { alert('Hello!'); } }); }); }); </script> <div id="content"><?php echo $content; ?></div> ajax.php echo json_encode($_POST['content']); ?> Nothing happens... WhatI really want to achieve is to get that alert box and get the return data, but I am lost since I don't get any errors or nothing.

    Read the article

  • Using CouchDB to serve HTML.

    - by alxross
    I'm trying to use CouchDB with HTML/standalone REST architecture. That is, no other app server other than CouchDB and ajax style javascript calling CouchDB. It looks like cross scripting is a problem. I was using Cloudkit/Tokyo Cabinet before and it seems like the needed callback function was screwing it up in the URL. Now I'm trying CouchDB and getting the same problem. Here are my questions: 1) Are these problems because the REST/JSON store like CouchDB or CloudKit is running on a different port from my web page? They're both run locally and called from "localhost". 2) Should I let CouchDB host my page and serve the HTML? 3) How do I do this? The documentation didnt seem so clear... Thanks, Alex

    Read the article

  • android, find the nearest location without going through all the locations

    - by Marwan
    I am building a taxi dispatching app first: I need the passenger app to show the nearest taxis, now I know how to do that in code but in my way I have to go through all the taxis locations(in database on server) and calculate the distance from the passenger location and get the lowest ones - I don't want to do this because there will be a lot of taxis and going through all of them and making some math is kind of pain on the server- is there a way to get the nearest ones without going through all of them? second: what the best database to use - first, should it be sql or non-sql - I need a very robust database, because there will be a lot of updates (I mean the passengers locations added then deleted when arriving to destination && the taxis location changes frequently) finally: I will use RubyOnRails to do the server side and json as data transfer format, do you have a recommendation to me on something better? Thanks

    Read the article

  • Server-side access to Client Browser's Latitude/Longitude using Django.

    - by ZenGyro
    Hello, So i am writing a little app that compares a user's position against a database on web-based server written using Django and performs some functions with it. Accessing the browser's geolocation data (in supported browsers ) is fairly trivial using JavaScript. But what is the best way to allow the Django server to access the longitude and latitude variables? Is it best to wrap them up as a JSON object and send to the server via POST? Or is there some easier (Geo)Django-based way to access the Navigator.geolocation browser object. Please forgive a newbie a question like this, but my Google-Fuing only seems to find ways to insert variables into JavaScript via template tag, whereas I need it to work the other way! Any advice or code snippets greatly appreciated. Feel free to talk to me like I am an idiot.

    Read the article

  • Handling JSON and HTML templates in jQuery

    - by Toby Hede
    I have an ajax-enabled site that presents a lot of dynamic content by interpolating JSON values with HTML. This all works fine. BUT it means I have significant amounts of HTML all through my JavaScript. For example: var template = "<div>Foo: {bar}</div><div>Blah: {vtha}</div>"; template.interpolate({bar:"bar",blah:"vtha"}); I have cut this down a fair bit - some of my dynamic elements have quite a lot of HTML and a lot going on. I am using jQuery and I am building on Rails, so if there is something smart in either framework, that would be great. For reference, the String interpolation function used above is: String.prototype.interpolate = function (o) { return this.replace(/{([^{}]*)}/g, function (a, b) { var r = o[b]; return typeof r === 'string' || typeof r === 'number' ? r : a; } ); };

    Read the article

  • jquery trouble with getJSON call.

    - by Yo-L
    Hi guys. Got some basic problem again. I need to modify a function that previously returned a in code written object. Im now trying to get the object from json through $.getJSON function getEventData() { var result = ''; $.getJSON("ajax.php?cmd=getbydate&fromdate=&todate=", function(data){ result = data; }); return result; } Problem is that result isn't set in the callback function for obvious reasons. Do you guys have a solution for this?

    Read the article

  • Problem with accessing in DOM with jQuery

    - by Tristan
    Hello, I changed the tree of my JSON-P output, and i cannot access to my object DOM anymore : Here's my output : jsonp1271634374310( {"Inter-Medias": {"name":"Inter-Medias","idGSP":"14","average":"80","services":"8.86"} }); And here's my jQuery script : success: function(data, textStatus, XMLHttpRequest){ widget = data.name; widget += data.average ; .... I know one level is missing, but if I try to do : data.Inter-Medias.name or data.name.name it's still not working. Any idea please ? I will have case where i'll have multiple Ojbect, so i want to display all of them, how to do that ? for (i=0;i < data.length;i++) Does it look right ? Bonus question : i understand function(data, textStatus, XMLHttpRequest) that in case of success this function is triggered, the data is what the script recieved from his request, but i have no idea what textStatus or XMLHttpRequest are here too and why ?! Thank you.

    Read the article

  • NSNull isEqualToString Issue With JSON Response

    - by IconicDigital
    I am getting the following error -[NSNull isEqualToString:]: unrecognized selector sent to instance 0x3c168090 on this line of code cell.offerTitle.text = [voucherData objectForKey:@"offer_title"]; Could someone help me correct the problem please? Thanks Oliver * Update ** NSlog [voucherData objectForKey:@"offer_title"] and I get the following 2012-12-05 16:50:17.512 app.co.uk - Vouchers and Deals[6350:907] <null> 2012-12-05 16:50:17.514 app.co.uk - Vouchers and Deals[6350:907] -[NSNull isEqualToString:]: unrecognized selector sent to instance 0x3c168090 Checked the JSON and there was a null value, I have done the following to check if null but this isn't working if([voucherData objectForKey:@"offer_title"] == NULL){ cell.offerTitle.text = @"INVALID"; }else{ cell.offerTitle.text = [voucherData objectForKey:@"offer_title"]; }

    Read the article

  • Convert long number as string in the serialization

    - by Bruno
    I have a custom made class that use a long as ID. However, when I call my action using ajax, my ID is truncated and it loses the last 2 numbers because javascript loses precision when dealing with large numbers. My solution would be to give a string to my javascript, but the ID have to stay as a long on the server side. Is there a way to serialize the property as a string? I'm looking for some kind of attribute. Controller public class CustomersController : ApiController { public IEnumerable<CustomerEntity> Get() { yield return new CustomerEntity() { ID = 1306270928525862486, Name = "Test" }; } } Model public class CustomerEntity { public long ID { get; set; } public string Name { get; set; } } JSON Result [{"Name":"Test","ID":1306270928525862400}]

    Read the article

  • PHP MySQL New Lines / Whitespaces from textarea

    - by rob_robsen
    I've a problem about whitespaces and new lines at the beginning of a textarea. I send a json string with ajax to the php script. Then I decode the string into an php array (with json_decode). So I have a string in this array with two line breaks at the beginning. If a print the text from the array, the line breaks are there, but if I store the text into the mysql database, the line breaks are gone... Only at the beginning of the string, the line breaks gone... At the rest of the string, the line breaks are ok. Thanks for your answers! rob

    Read the article

  • Need some explanation about MS Ajax using PageMethods

    - by Ahmed Said
    I have a project that uses PageMethods to call functions on the server. The server functions (written in C#) return the values as array of strings, without doing any kind of serialization and in the client side (from Js) the accessing of the return values is by using static variable called arguments. I found that sometimes for some users (cases are not repro) sometimes an exception occured "WebServiceFailedException the server method 'Foo' returned invalid data. the 'd' property is missing from JSON." Some searching on google I found that people are serializing the return values using DataContractJsonSerializer class and in js accessing the return value using one of the callback function Example: function OnRequestComplete(result, userContext, methodName) { var Person = eval('(' + result + ')'); alert(Person.Forename); alert(Person.Surname); } So is the first technique is correct? or what?

    Read the article

  • Design question?

    - by Mohamed
    I am building music app, where user can do several tasks including but not limited to listening song, like song, recommend song to a friend and extra. currently I have this model: class Activity(models.Model): activity = models.TextField() user = models.ForeignKey(User) date = models.DateTimeField(auto_now=True) so far I thought about two solutions. 1. saving a string to database. e.g "you listened song xyz" 2. create a dictionary about the activity and save to the database using pickle or json. e.g. dict_ = {"activity_type":"listening", "song":song_obj} I am leaning to the second implementation, but not quite sure. so what do you think about those two methods? do you know better way to achieve the goal?

    Read the article

  • Key-value pair request in ASIFormDataRequest does not get response

    - by onkar
    I am sending a key-value pair inorder to get jSON response.I am trying this way. NSString *url = SAMPLE_URL; ASIFormDataRequest *request =[[[ASIFormDataRequest alloc] init] autorelease]; request=[ASIFormDataRequest requestWithURL:url]; // NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; //[request setURL:[NSURL URLWithString:url]]; [request setHTTPMethod:@"POST"]; [request setPostValue:@"admin" forKey:@"username"]; [request setPostValue:@"123456" forKey:@"password"]; Issue The code is running fine, but no-response/acknowledgement is obtained. EDIT 1 [request setHTTPMethod:@"POST"]; has been changed to [request setRequestMethod:@"POST"];

    Read the article

  • wait for ajax request then finish the rest ( jQuery )

    - by user1725155
    I have a peace of jquery code: var new = checkCP(somedata); if(new=="hi"){ alert("Welcom"); } function checkCP(jsData){ $.ajax({ type: "POST", url: "Process.php", data: jsData, dataType: "json", success: function(data){ if(data.match==1) return "hi"; else return "bye"; } }); } I don't know why the welcome alert never show up . I checked everything , even on PHP file the result is 1 but apparently before It wait for ajax respond it passes the if(new=="hi"){ alert("Welcom"); } So is there anyway to wait for ajax respond then read the rest of codes in jQuery ? Thanks.

    Read the article

  • Parsing array data

    - by Sam
    I am trying to parse this array data that way generated from JQuery and JSON. Array ( [d] = Array ( [0] = Array ( [order] = 1 ) [1] => Array ( [order] => 2 ) [2] => Array ( [order] => 3 ) [3] => Array ( [order] => 4 ) [4] => Array ( [order] => 5 ) ) ) I am trying to save the above date into a mysql table, but cannot seem to parse the data properly to be inserted into the database. Can anyone help?

    Read the article

  • .net MVC, dealing with json and Areas

    - by JoseMarmolejos
    When not using areas dealing with the url for the JsonResults from the clientside is not much of a pain, usually you can get away with hardcoding the url into your json calls and get away with it. Problem arises when you have different areas and you don't want to update all your links when you move a controller (and its views) from one area to the other. I'm not very satisfied with the way I'm handling this scenario by having this chunk of code inside every view: <script type="text/javascript"> var ControllerActions = { JsonSearch: '<%= Url.Action("JsonSearch") %>/', JsonDelete: '<%= Url.Action("JsonDelete") %>/', Edit: '<%= Url.Action("Edit") %>/', Delete: '<%= Url.Action("Delete") %>/' } </script> While it does work no matter where I place the views/controllers I wonder if there's a more elegant to do this.

    Read the article

  • What the best way to convert from String to HashMap?

    - by eugenn
    I would like to serialize a Java HashMap to string representation. The HashMap will contains only primitive values like string and integer. After that this string will be stored to db. How to restore back the HashMap? Is it make sense to use BeanUtils and interface Converter or use JSON? For example: List list = new ArrayList(); list.add(new Long(1)); list.add(new Long(2)); list.add(new Long(4)); Map map = new HashMap(); map.put("cityId", new Integer(1)); map.put("name", "test"); map.put("float", new Float(-3.2)); map.put("ids", list); map.toString() -> {float=-3.2,ids=[1, 2, 4],name=test,cityId=1} map.toJSON -> {"float":-3.2,"ids":[1,2,4],"name":"test","cityId":1}

    Read the article

  • Connecting to TFS via ASP.NET, jQuery and Phonegap

    - by Tony D.
    I want to develop a mobile application that would allow the user the ability to run a suite of automated test cases housed in TFS. This is something I thought of this morning so it's all still very preliminary. But I'm curious as to what would be the best route for something like this? Or if it's even possible? Because the mobile devices from the users will vary from iphones to droids, I would probably want to incorporate something like Phonegap for it's cross platform capabilities. My initial thought was to develop in ASP.net/C# (which would be stored on a remote server), and have jQuery make calls to that server. Not sure if that would be the most appropriate way of handling this. I'm not too familiar with JSON but I have seen it as a suggestion on various sites to handle the returned data. Any thoughts or suggestions are appreciated. Thanks.

    Read the article

  • PHP: Accessing an object property with a variable.

    - by Peter
    Let's assume I have an array of object properties I'd like to access: $properties = array('foo', 'bar'); I'd like to loop through the object and access these properties dynamically (specifically, I'm trying to dynamically handle missing JSON elements based on an array of expected elements): foreach ($data as $item) { foreach ($properties as $property) { if (empty($item->{$property})) { // Do something } } } Each $item in $data should have the properties 'foo' and 'bar'. If empty(), I'll handle them. I'm trying to get the loop (in line 3) to access $item-{'foo'} and $item-{'bar'}, but it's not working. Any idea why? Thanks!

    Read the article

  • Make jquery array out of div

    - by Industrial
    Hi everyone, Each div with the class "row" is added upon request from the user, to be able to add multiple items at once. So now is the question how I'll collect all the forms in to an array that PHP can read (like JSON for instance). I'll guess that there's already some easy and effective way of doing this? <div class="container"> <div class="row"> <input type="text" name="value1" id="textfield" /> <input type="text" name="value2" id="textfield" /> <input type="text" name="value3" id="textfield" /> </div> </div> Here's what I would like to achieve out of the shown example: array( array ('value1' => '', 'value2' => '', 'value3' => '') ); Thanks!

    Read the article

  • Django shell command to change a value in json data

    - by crozzfire
    I am a django newbie and i was playing around in django's manage.py shell. Here is something i am trying in the shell: >>> data [{'primary_program': False, 'id': 3684}, {'primary_program': True, 'id': 3685}] >>> data[0] {'primary_program': False, 'id': 3684} >>> data[1] {'primary_program': True, 'id': 3685} >>> data[0].values() [False, 3684] >>> data[1].values() [True, 3685] >>> How should i give a command here to update the value of primary_program in data[1] to False and keep the rest of the json the same?

    Read the article

  • formatting european characters from JSON results

    - by mlecho
    hi, i am building an application that imports JSON results and parses the objects to a table cell. Nothing fancy, but in my results, many of the terms/names are European with characters such as è or ú which come out as \u00E9 or \u00FA. I think these are ASCII ? or unicode? ( i can never keep em staight). Anyway, like all good NSSTring's, i figured there must be a method to fix this, but i am not finding it....any ideas? I am trying to avoid doing something like this: this posting. Thanks all.

    Read the article

  • How to bring Webserive text into a Winform aplication

    - by CogentP
    I am working a Winform Application that needs to access a webservice to get some basic information. The webservice exists, and the following is a link that brings text. Which basically is the customer name in Json format. http://globalbox.com.py/api/getUSER.php?gb=3217 So, my point, i need to be able to read the name of the customer and put that into a string variable. How do I read this from Winforms? I have no idea how to go about doing this... please help. Visual Basic code would be better, or else C# will do. thanks in advance!!

    Read the article

  • How to customize the to_json method in rails3?

    - by lashleigh
    I want to convert an array of Place objects to json, I've been doing it like this: var places = <%= @places.to_json.html_safe %>; The only problem is that every place in the @places array has an associated tag list that doesn't get included. I'm using the acts_as_taggable_on gem to handle tags, so to get the tag list for a place I need to say place.tag_list. What do I have to do to get the tag_list included for each place in the javascript array? I think I'll need to write my own to_json method but I don't know how. Thanks

    Read the article

< Previous Page | 71 72 73 74 75 76 77 78 79 80 81 82  | Next Page >