Search Results

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

Page 54/235 | < Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >

  • JavaScript Data Binding Frameworks

    - by dwahlin
    Data binding is where it’s at now days when it comes to building client-centric Web applications. Developers experienced with desktop frameworks like WPF or web frameworks like ASP.NET, Silverlight, or others are used to being able to take model objects containing data and bind them to UI controls quickly and easily. When moving to client-side Web development the data binding story hasn’t been great since neither HTML nor JavaScript natively support data binding. This means that you have to write code to place data in a control and write code to extract it. Although it’s certainly feasible to do it from scratch (many of us have done it this way for years), it’s definitely tedious and not exactly the best solution when it comes to maintenance and re-use. Over the last few years several different script libraries have been released to simply the process of binding data to HTML controls. In fact, the subject of data binding is becoming so popular that it seems like a new script library is being released nearly every week. Many of the libraries provide MVC/MVVM pattern support in client-side JavaScript apps and some even integrate directly with server frameworks like Node.js. Here’s a quick list of a few of the available libraries that support data binding (if you like any others please add a comment and I’ll try to keep the list updated): AngularJS MVC framework for data binding (although closely follows the MVVM pattern). Backbone.js MVC framework with support for models, key/value binding, custom events, and more. Derby Provides a real-time environment that runs in the browser an in Node.js. The library supports data binding and templates. Ember Provides support for templates that automatically update as data changes. JsViews Data binding framework that provides “interactive data-driven views built on top of JsRender templates”. jQXB Expression Binder Lightweight jQuery plugin that supports bi-directional data binding support. KnockoutJS MVVM framework with robust support for data binding. For an excellent look at using KnockoutJS check out John Papa’s course on Pluralsight. Meteor End to end framework that uses Node.js on the server and provides support for data binding on  the client. Simpli5 JavaScript framework that provides support for two-way data binding. WinRT with HTML5/JavaScript If you’re building Windows 8 applications using HTML5 and JavaScript there’s built-in support for data binding in the WinJS library.   I won’t have time to write about each of these frameworks, but in the next post I’m going to talk about my (current) favorite when it comes to client-side JavaScript data binding libraries which is AngularJS. AngularJS provides an extremely clean way – in my opinion - to extend HTML syntax to support data binding while keeping model objects (the objects that hold the data) free from custom framework method calls or other weirdness. While I’m writing up the next post, feel free to visit the AngularJS developer guide if you’d like additional details about the API and want to get started using it.

    Read the article

  • Code and Slides: Building the Account at a Glance ASP.NET MVC, EF Code First, HTML5, and jQuery Application

    - by dwahlin
    This presentation was given at the spring 2012 DevConnections conference in Las Vegas and is based on my Pluralsight course. The presentation shows how several different technologies including ASP.NET MVC, EF Code First, HTML5, jQuery, Canvas, SVG, JavaScript patterns, Ajax, and more can be integrated together to build a robust application. An example of the application in action is shown next: View more of my presentations here. The complete code (and associated SQL Server database) for the Account at a Glance application can be found here. Check out the full-length course on the topic at Pluralsight.com.

    Read the article

  • Pluralsight Meet the Author Podcast on Building ASP.NET MVC Applications with HTML5 and jQuery

    - by dwahlin
    In the latest installment of Pluralsight’s Meet the Author podcast series, Fritz Onion and I talk about my new course, Building ASP.NET MVC Apps with Entity Framework Code First, HTML5, and jQuery.  In the interview I describe how the course provides a complete end-to-end view of building an application using multiple technologies.  I go into some detail about how the data access layer was built as well as how the UI works. Listen to it below:   Meet the Author:  Dan Wahlin on Building ASP.NET MVC Apps with Entity Framework Code First, HTML5, and jQuery

    Read the article

  • Code and Slides from my Fall 2012 DevConnections Talks

    - by dwahlin
    Thanks to everyone who attended my sessions at the Fall 2012 DevConnections conference in Las Vegas. There was a ton of interest in different JavaScript and HTML5 topics. Here’s a picture taken after finishing up my first talk. The second one was packed (standing room only…forgot to take a picture though unfortunately) – thanks to everyone for the great questions and interest in the sessions! I really enjoyed talking with everyone that came up afterward.   As promised, here’s where you can find the code and slides I demonstrated during my talks on building an HTML5 application with a variety of technologies and structuring JavaScript code. Building the Account at a Glance ASP.NET MVC, HTML5 and jQuery Application Structuring JavaScript Code - Techniques, Strategies and Patterns If you’re on Twitter keep in touch with me through my DanWahlin alias.

    Read the article

  • How can one prevent double encoding of html entities when they are allowed in the input

    - by Bob
    How can I prevent double encoding of html entities, or fix them programmatically? I am using the encode() function from the HTML::Entities perl module to encode HTML entities in user input. The problem here is that we also allow users to input HTML entities directly and these entities end up being double encoded. For example, a user may enter: Stackoverflow & Perl = Awesome&hellip; This ends up being encoded to Stackoverflow &amp; Perl = Awesome&amp;hellip; This renders in the browser as Stackoverflow & Perl = Awesome&hellip; We want this to render as Stackoverflow & Perl = Awesome... Is there a way to prevent this double encoding? Or is there a module or snippet of code that can easily correct these double encoding issues? Any help is greatly appreciated!

    Read the article

  • Lost in UTF-8 hell. (Django and Python)

    - by user140314
    I am working through the Django RSS reader project here. The RSS feed will read something like "OKLAHOMA CITY (AP) — James Harden let". The RSS feed's encoding reads encoding="UTF-8" so I believe I am passing utf-8 to markdown in the code snippet below. The em dash is where it chokes. I get the Django error of "'ascii' codec can't encode character u'\u2014' in position 109: ordinal not in range(128)" which is an UnicodeEncodeError. In the variables being passed I see "OKLAHOMA CITY (AP) \u2014 James Harden". The code line that is not working is: content = content.encode(parsed_feed.encoding, "xmlcharrefreplace") I am using markdown 2.0, django 1.1, and python 2.4. What is the magic sequence of encoding and decoding that I need to do to make this work? Thanks.

    Read the article

  • Is sending a PDF as encoded byte array in XML sensible

    - by simonjwoods
    Hi I am looking to return a PDF from a webservice call. (ATM, a custom proxy is required at the client-side) AFAICS, there are 2 ways of doing it a) Return the link to a web-accessible location b) Encode the PDF and include it in the XML In my circumstance, a) will require 2 trips from the client, the first to get the path and the second to get the file. However, wrt b), this link (http://www.coderanch.com/t/279020/Streams/java/wrting-bytearray-xml-file#1283263) suggests that it isn't a good idea to encode a PDF, though without explanation. I'd be grateful if someone would offer recommendations of the above (and potentially, other alternatives). Many thx Simon

    Read the article

  • IIS 7.5 truncating POST body containing JSON data with ASP.NET MVC 3

    - by Guneet Sahai
    I'm facing a problem which I hope is a configuration thing with IIS but is right now giving a lot of trouble. Basically I have a controller that accepts a JSON and does some processing. While it generally works fine, but every now and then when the system has some load I get an error. After some painful debugging, we figured the incoming JSON gets truncated which causes the deserialzer to fail. To narrow down the problem - we wrote a simple controller that accepts a JSON and tries to deserialize it. In case it fails it just logs it. This works fine but when I hit it using a load testing tool (JMeter) it throws the same error (truncation) for a few requests. The # of failures increased when I increase parallel connections. It starts showing with 150 concurrent requests. We are running IIS 7 on windows 2008 server with ASP.Net MVC 3 with more or less default configuration of IIS. More information available in my question below http://stackoverflow.com/questions/12662282/content-length-of-http-request-body-size

    Read the article

  • Encode audio to aac with libavcodec

    - by ryan
    I'm using libavcodec (latest git as of 3/3/10) to encode raw pcm to aac (libfaac support enabled). I do this by calling avcodec_encode_audio repeatedly with codec_context-frame_size samples each time. The first four calls return successfully, but the fifth call never returns. When I use gdb to break, the stack is corrupt. If I use audacity to export the pcm data to a .wav file, then I can use command-line ffmpeg to convert to aac without any issues, so I'm sure it's something I'm doing wrong. I've written a small test program that duplicates my problem. It reads the test data from a file, which is available here: http://birdie.protoven.com/audio.pcm (~2 seconds of signed 16 bit LE pcm) I can make it all work if I use FAAC directly, but the code would be a little cleaner if I could just use libavcodec, as I'm also encoding video, and writing both to an mp4. ffmpeg version info: FFmpeg version git-c280040, Copyright (c) 2000-2010 the FFmpeg developers built on Mar 3 2010 15:40:46 with gcc 4.4.1 configuration: --enable-libfaac --enable-gpl --enable-nonfree --enable-version3 --enable-postproc --enable-pthreads --enable-debug=3 --enable-shared libavutil 50.10. 0 / 50.10. 0 libavcodec 52.55. 0 / 52.55. 0 libavformat 52.54. 0 / 52.54. 0 libavdevice 52. 2. 0 / 52. 2. 0 libswscale 0.10. 0 / 0.10. 0 libpostproc 51. 2. 0 / 51. 2. 0 Is there something I'm not setting, or setting incorrectly in my codec context, maybe? Any help is greatly appreciated! Here is my test code: #include <stdio.h> #include <libavcodec/avcodec.h> void EncodeTest(int sampleRate, int channels, int audioBitrate, uint8_t *audioData, size_t audioSize) { AVCodecContext *audioCodec; AVCodec *codec; uint8_t *buf; int bufSize, frameBytes; avcodec_register_all(); //Set up audio encoder codec = avcodec_find_encoder(CODEC_ID_AAC); if (codec == NULL) return; audioCodec = avcodec_alloc_context(); audioCodec->bit_rate = audioBitrate; audioCodec->sample_fmt = SAMPLE_FMT_S16; audioCodec->sample_rate = sampleRate; audioCodec->channels = channels; audioCodec->profile = FF_PROFILE_AAC_MAIN; audioCodec->time_base = (AVRational){1, sampleRate}; audioCodec->codec_type = CODEC_TYPE_AUDIO; if (avcodec_open(audioCodec, codec) < 0) return; bufSize = FF_MIN_BUFFER_SIZE * 10; buf = (uint8_t *)malloc(bufSize); if (buf == NULL) return; frameBytes = audioCodec->frame_size * audioCodec->channels * 2; while (audioSize >= frameBytes) { int packetSize; packetSize = avcodec_encode_audio(audioCodec, buf, bufSize, (short *)audioData); printf("encoder returned %d bytes of data\n", packetSize); audioData += frameBytes; audioSize -= frameBytes; } } int main() { FILE *stream = fopen("audio.pcm", "rb"); size_t size; uint8_t *buf; if (stream == NULL) { printf("Unable to open file\n"); return 1; } fseek(stream, 0, SEEK_END); size = ftell(stream); fseek(stream, 0, SEEK_SET); buf = (uint8_t *)malloc(size); fread(buf, sizeof(uint8_t), size, stream); fclose(stream); EncodeTest(32000, 2, 448000, buf, size); }

    Read the article

  • Problems with jQuery getJSON using local files in Chrome

    - by Tauren
    I have a very simple test page that uses XHR requests with jQuery's $.getJSON and $.ajax methods. The same page works in some situations and not in others. Specificially, it doesn't work in Chrome on Ubuntu. I'm testing on Ubuntu 9.10 with Chrome 5.0.342.7 beta and Mac OSX 10.6.2 with Chrome 5.0.307.9 beta. It works correctly when files are installed on a web server from both Ubuntu/Chrome and Mac/Chrome (try it out here). It works correctly when files are installed on local hard drive in Mac/Chrome (accessed with file:///...). It FAILS when files are installed on local hard drive in Ubuntu/Chrome (access with file:///...). The small set of 3 files can be downloaded in a tar/gzip file from here: http://issues.tauren.com/testjson/testjson.tgz When it works, the Chrome console will say: XHR finished loading: "http://issues.tauren.com/testjson/data.json". index.html:16Using getJSON index.html:21 Object result: "success" __proto__: Object index.html:22success XHR finished loading: "http://issues.tauren.com/testjson/data.json". index.html:29Using ajax with json dataType index.html:34 Object result: "success" __proto__: Object index.html:35success XHR finished loading: "http://issues.tauren.com/testjson/data.json". index.html:46Using ajax with text dataType index.html:51{"result":"success"} index.html:52undefined When it doesn't work, the Chrome console will show this: index.html:16Using getJSON index.html:21null index.html:22Uncaught TypeError: Cannot read property 'result' of null index.html:29Using ajax with json dataType index.html:34null index.html:35Uncaught TypeError: Cannot read property 'result' of null index.html:46Using ajax with text dataType index.html:51 index.html:52undefined Notice that it doesn't even show the XHR requests, although the success handler is run. I swear this was working previously in Ubuntu/Chrome, and am worried something got messed up. I already uninstalled and reinstalled Chrome, but that didn't help. Can someone try it out locally on your Ubuntu system and tell me if you have any troubles? Note that it seems to be working fine in Firefox.

    Read the article

  • [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

    - by gnomixa
    In ASP.net web service if the above isn't specified , what is the response format by default? Also, if my web service below: [WebMethod()] public List<Sample> GenerateSamples(string[][] data) { ResultsFactory f = new ResultsFactory(data); List<Sample> samples = f.GenerateSamples(); return samples; } returns the list of objects, If I change the response format to JSON, I have to change the return type to string, then how do I access objects in my javascript? Currently I call this web service in my JS such as: $.ajax({ type: "POST", url: "http://localhost/TemplateWebService/Service.asmx/GenerateSamples", data: jsonText, contentType: "application/json; charset=utf-8", dataType: "json", success: function(response) { var samples = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d; if (samples.length > 0) { doSomethingHere(samples); } else { alert("No samples have been generated"); } }, error: function(xhr, status, error) { var msg = JSON.parse(xhr.responseText); alert(msg.Message); } }); What i noticed though, even though everything works perfectly fine, the eval statement never gets executed, which means that the web service always returns a string! So my question is, is [ScriptMethod(ResponseFormat = ResponseFormat.Json)] necessary on the web service definition side? The way things are now, I can use samples array and access each object and its properties as I normally would in any OOP code, which is very convenient, and everything works no problem, but I just wanted to make sure that I am not missing anything in my set up. I took the basics of combining Jquery's ajax with asp.net from Encosia side, and the response type wasn't mentioned there - I read it on another site and am I not sure how vital it is.

    Read the article

  • Zend_Json::decode returning null

    - by davykiash
    Am trying to validate my form using an AJAX call $("#button").click(function() { $.ajax({ type: "POST", url: "<?php echo $this->baseUrl() ?>/expensetypes/async", data: 'fs=' + JSON.stringify($('#myform').serialize(true)), contentType: "application/json; charset=utf-8", dataType: "json" }); }); On my controller my code is as follows //Map the form from the client-side call $myFormData = Zend_Json::decode($this->getRequest()->getParam("fs") ,Zend_Json::TYPE_ARRAY); $form = new Form_Expensetypes(); $form->isValid($myFormData); My problem is that I cannot validate since Zend_Form::isValid expects an array Am not quite sure wether the problem is at my serialisation at the client end or Zend_Json::decode function does not function with this kind of JSON parsing.

    Read the article

  • Error about 'invalid JSON' with couchDB view but the json's fine...

    - by Chris Huang-Leaver
    I am trying to setup the following view on CouchDB { "_id":"_design/id", "_rev":"1-9be2e55e05ac368da3047841f301203d", "language":"javascript", "views":{ "by_id":{ "map" : "function(doc) { emit(doc.id, doc)}" },"from_user_id":{ "map" : "function(doc) { if (doc.from_user_id) {emit(doc.from_user_id, doc)}}"}, "from_user":{ "map" : "function(doc) { if (doc.from_user) {emit(doc.from_user, doc)}}"}, "to_user_id":{ "map" : "function(doc) {if (doc.to_user_id){ emit(doc.to_user_id, doc)}}"}, "to_user":{ "map" : "function(doc) {if (doc.to_user){ emit(doc.to_user, doc)}}" }, "max_id":{ "map" : "function(doc) { if (doc.id) {emit(doc._id, eval(doc.id))}}", "reduce" :"function(key,value) { a = value[0]; for (i=1; i <value.length; ++i){a = Math.max(a,value[i])} return a}" } } } when I try to 'PUT' this using curl: curl -X PUT -d keys.json $CDB/_design/id {"error":"bad_request","reason":"invalid UTF-8 JSON"} I know it's not invalid JSON, because I tested it using the 'json' library built into Python 2.6, it loads fine. JS screw ups give me the error 'must evaluate to a function' What else might be wrong with it?

    Read the article

  • Namespace Orginization and Conventions

    - by Bob Dylan
    So I have a little bit of a problem. I working on a project in C# using The StackOveflow API. You can send it a request like so: http://stackoverflow.com/users/rep/126196/2010-01-01/2010-03-13 And get back something like this JSON response: [{"PostUrl":"1167342", "PostTitle":"Are ref and out in C# the same a pointers in C++?", "Rep":10}, {"PostUrl":"1290595", "PostTitle":"Where can I find a good tutorial on bubbling?", "Rep":10} ... So my problem is that I have some methods like GetJsonResponse() which return the above JSON and SaveTempFile() which saves that JSON response to a temporary file for later use. I not sure if I should create a class for them, or what namespace to put them under. Right now my current namespace hierarchy is like so: StackOverflow.Api.Json. So how should I organize these methods/classes/namespaces?

    Read the article

  • How to either return JSON or RedirectToAction?

    - by DaveDev
    I have an Action Method that I'd either like to return JSON from on one condition or redirect on another condition. I thought that I could do this by returning ActionResult from my method but doing this causes the error "not all code paths return a value" Can anyone tell me what I'm doing wrong? Or how to achieve the desired result? Here's the code below: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Login(User user) { var myErrors = new Dictionary<string, string>(); try { if (ModelState.IsValid) { if (userRepository.ValidUser(user)) { RedirectToAction("Index", "Group"); //return Json("Valid"); } else { return Json("Invalid"); } } else { foreach (KeyValuePair<string, ModelState> keyValuePair in ViewData.ModelState) { if (keyValuePair.Value.Errors.Count > 0) { List<string> errors = new List<string>(); myErrors.Add(keyValuePair.Key, keyValuePair.Value.Errors[0].ErrorMessage); } } return Json(myErrors); } } catch (Exception) { return Json("Invalid"); } }

    Read the article

  • Reflection Permission problems when using the GSON library in a applet.

    - by mridang
    I'm writing an Applet that makes some JSON-RPC calls. I'm using the Google JSON library (GSON) to cast the response JSON into a class. Thsi seems to work fine as is but when I use this code in my Applet, I'm hit with a java.lang.reflect.reflectpermission. From what I read on this thread on SO, it seems that since GSON uses Reflection, I cannot use it in Applets unless I explicitly modify the security policy. How can I get around this? I've created a bunch of classes in my application and was using the Gson.fromJson method to cast it into the class. Is there any way to achieve the same functionality without having to re-write half my code. (The complexity of dealing with JSON in Java seems to be in a league of its own!) Thanks in advance guys.

    Read the article

  • Prototypejs .evalJSON not returning object

    - by Pselus
    I have this JSON (which validates according to JSONLint): [ { "BugCount":"2", "BugTitle":"C:\\INETPUB\\WWWROOT\\CLUBREADY2\\TRAINERS\\../Connections/LTC.asp", "ErrLine":"141", "BugID":"702" }, { "BugCount":"1", "BugTitle":"/admin/ajax_logagreementsig.asp", "ErrLine":"0", "BugID":"1322" }, ] However, when I run data = json.evalJSON on it I get some problems. If I run .evalJSON(true) (to sanitize) an error happens within prototype saying "json" is undefined. The same happens if I do .evalJSON(). If I do .evalJSON with no parenthesis, then data is just an empty object and no error happens. Is there something wrong with my JSON?

    Read the article

  • Using JQuery getJSON method

    - by nav
    Hi, I am attempting to pase a a JSON data using the JQuery getJSON function. The REST query is: http://query.yahooapis.com/v1/public/yql?q=select%20woeid%20from%20geo.places%20where%20text%20%3D%20%22london%22&format=json&jsoncallback=? The script I'm using to parse 'data' to obtain the WOEID value doesnt seem to work below: $.getJSON("http://query.yahooapis.com/v1/public/yql?"+ "q=select%20woeid%20from%20geo.places%20where%20text%20%3D%20%22"+ "london"+ "%22&format=json&jsoncallback=?", function(data){ console.log("json: " + data); var datatmp = data; if(data.results[0]){ var data = filterData(data.results.place[0]); } } ); Can anyone say what I'm doing wrong? link text

    Read the article

  • [C#] Namespace Orginization and Conventions

    - by Bob Dylan
    So I have a little bit of a problem. I working on a project in C# using The StackOveflow API. You can send it a request like so: http://stackoverflow.com/users/rep/126196/2010-01-01/2010-03-13 And get back something like this JSON response: [{"PostUrl":"1167342", "PostTitle":"Are ref and out in C# the same a pointers in C++?", "Rep":10}, {"PostUrl":"1290595", "PostTitle":"Where can I find a good tutorial on bubbling?", "Rep":10} ... So my problem is that I have some methods like GetJsonResponse() which return the above JSON and SaveTempFile() which saves that JSON response to a temporary file for later use. I not sure if I should create a class for them, or what namespace to put them under. Right now my current namespace hierarchy is like so: StackOverflow.Api.Json. So how should I organize these methods/classes/namespaces?

    Read the article

  • Query JSON String

    - by Theofanis Pantelides
    Hi, Is there a way to query a JSON (String) for a specific item? ie: String jSon = "{\"a\":{\"b\":27472483,\"c\":\"123\"}}"; such that: Int32 bob = (Int32)getFromJSON("a.b", jSon); // bob == 27472483 Thank you, -Theo

    Read the article

  • JSON - msg.d is undefined error

    - by Narmatha Balasundaram
    Hi - Webmethod returns an array of objects - something like this {"d": [[{"Amount":100,"Name":"StackOverflow"}, {"Amount":200,"Name":"Badges"}, {"Amount":300,"Name":"Questions"}]]} On the client-side, when the JSON is referenced using msg.d, I get a msg.d is undefined error. I am using jQuery JavaScript Library v1.4.2 How do I access the elements in the array of objects? Adding more findings, code and questions: I don't see __type in the JSON object that is returned. Does that mean that the object sent from the server is not JSON formatted? When the __type is not a part of the response, I will not be able to use msg.d? (msg.d is undefined) Some more: 1. I can access the elements from client side using msg[0][0].Amount - How can I specifically JSON format my return object (from the server)

    Read the article

< Previous Page | 50 51 52 53 54 55 56 57 58 59 60 61  | Next Page >