Search Results

Search found 4116 results on 165 pages for 'baron throw'.

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

  • File.Exists() returns false, but not in debug

    - by Tor Haugen
    I'm being completely confused here folks, My code throws an exception because File.Exists() returns false public override sealed TCargo ReadFile(string fileName) { if (!File.Exists(fileName)) { throw new ArgumentException("Provided file name does not exist", "fileName"); } Visual studio breaks at the throw statement, and I immediately check the value of File.Exists(fileName) in the immediate window. It returns true. When I drag the breakpoint back up to the if statement and execute it again, it throws again. fileName is an absolute path to a file. I'm not creating the file, nor writing to it (it's there all along). If I paste the path into the open dialog in Notepad, it reads the file without problems. The code is executing in a background worker. It's the only complicating factor I can think of. I am positive the file has not been opened already, either in the worker thread or elsewhere. What's going on here?

    Read the article

  • Correct Exceptions in C++

    - by Dr.Ackula
    I am just learning how to handle errors in my C++ code. I wrote this example that looks for a text file called some file, and if its not found will throw an exception. #include <iostream> #include <fstream> using namespace std; int main() { int array[90]; try { ifstream file; file.open("somefile.txt"); if(!file.good()) throw 56; } catch(int e) { cout<<"Error number "<<e<<endl; } return 0; } Now I have two questions. First I would like to know if I am using Exceptions correctly. Second, (assuming the first is true) what is the benefit to using them vs an If else statement?

    Read the article

  • terminated value of Eclipse

    - by helloWorld
    I have some function: void addNormalLine(int id, LineNumber number, Rate smsRate, Rate callRate) { list<Account>::iterator iAccounts; findAccount(iAccounts, id); if(iAccounts == listOfAccounts.end()){ throw "AccountDoesNotExist"; } if(lineExists(number)){ throw "LineExists"; } else{ iAccounts->increaseNumLines(); shared_ptr<Line> currentLine(new Line(id, number, smsRate, callRate)); //here I have some problems listOfLines.push_back(currentLine); //without these two rows it works, but didn't add lines to my list } } Account, Rate, LineNumber - some classes but It always add only one or two numbers, if I add 3 it always terminates and and I recieve terminated, exit value: 3, I tried google it, but didn't find, what is than supposed to mean, thanks in advance

    Read the article

  • Xcode 3.2 not recompiling changed files

    - by Jason
    I've been programming a new iPhone application and everything has been chugging along fine, until this afternoon when I noticed that any changes I was making were not being reflected in the actual app! Even code that throws errors isn't getting picked up by the compiler. To get around this, I have taken to the following procedure: Finish making my edits, and add code to the file which will always throw a compiler error. Right-click the file I have just edited, and hit "Compile" to just compile that one file; it will throw the error. Remove the error-producing code, and again right-click and "Compile" the one file. Build the whole project This is quite annoying, and I can't figure out why this would suddenly happen to my Xcode project. Any thoughts on what could be causing this, and how to fix it?

    Read the article

  • SWIG: Throwing exceptions from Python to C++

    - by wheaties
    We've got an interface we've defined in C++ (abstract class, all functions pure virtual) which will be extended in Python. To overcome the cross-language polymorphism issues we're planning on using SWIG directors. I've read how to catch exceptions thrown from C++ code in our Python code here, here, here, and even on SO. It's fairly straight forward and I'm not expecting issues with handling our library's own exceptions. What I'd like to know and can't seem to find in the documentation is how to have our Python implementation of the extended C++ interface throw those C++ exceptions in a way that makes them visible to the C++ code. We could make small functions within the *.i files such that each function throws our exceptions: void throw_myException(){ throw MyException; } but I'm wondering how it will interact with the Python code. Anyone have any experience with throwing C++ exceptions from Python code?

    Read the article

  • javascript popup on refreshing page

    - by vatismarty
    I have written code like this to throw a pop up when my website is closed. But this throws the pop up even if i refresh my page. Please help me to throw popup only when i close the browser of that website. <body onunload="javascript: exitpop()"> <script type="text/javascript"> function exitpop() { my_window= window.open ("","mywindow1","status=1,width=600,height=400"); my_window.document.write('<h1>My Team</h1><p>Thank you</p><p>If you accidentally closed website click <a href="http://www.google.com">here</a> to go back to our website</p>'); }.

    Read the article

  • boost variant static_visitor problem picking correct function

    - by Steve
    I'm sure I'm having a problem with template resolution here, but I'm not sure why I'm having the problem. I have a static visitor I'm passing to boost variant where i've had to do template specialization for certain cases. The case for everything except for MyClass should throw in the static_visitor below. Unfortunately, when the visitor is applied to pull a MyClass out, it selects the most generic case rather than the exact match. I would type each case explicitly, but that will be rather long. So, why is the compiler resolving the most generic case over the exact match, and is there anyway to fix it template<> class CastVisitor<MyClass>:public boost::static_visitor<MyClass> { public: template<typename U> MyClass operator()(const U & i) const { throw std::exception("Unable to cast"); } MyClass operator()(const MyClass& i) { return i; } };

    Read the article

  • FETCH INTO doesn't raise an exception if the set is empty, does it?

    - by Cade Roux
    Here is some actual code I'm trying to debug: BEGIN OPEN bservice (coservice.prod_id); FETCH bservice INTO v_billing_alias_id, v_billing_service_uom_id, v_summary_remarks; CLOSE bservice; v_service_found := 1; -- An empty fetch is expected for some services. EXCEPTION WHEN OTHERS THEN v_service_found := 0; END; When the parametrized cursor bservice(prod_id) is empty, it fetches NULL into the three variables and does not throw an exception. So whoever wrote this code expecting it to throw an exception was wrong, right? The comment seems to imply that and empty fetch is expected and then it sets a flag for later handling, but I think this code cannot possibly have been tested with empty sets either. Obviously, it should use bservice%NOTFOUND or bservice%FOUND or similar.

    Read the article

  • Custom Response + HTTP status?

    - by Cristian Boariu
    Hi, I have a rest interface for my project. For one class i have a POST method where you can post an xml and i RETURN a custom response like: <userInvitation>Invalid email</userInvitation> if the email from the xml which was posted, was incorrect + other custom messages i have defined for different situations. For all of these the HTTP STATUS is automatically put on 200 (OK). Is there any way to change it? Ps: I know that i can throw a web application like : throw new WebApplicationException(Response.Status.BAD_REQUEST); but in this case my custom response is no more included. So i just want to return my custom error + 400 as http response. Thanks in advance.

    Read the article

  • Exception during processing XSLT transformation!

    - by Artic
    I'm using this code to generate contents file. try { StreamResult result = new StreamResult(); TransformerFactory tf = TransformerFactory.newInstance(); Templates templ = tf.newTemplates(xsltSource); Transformer transf = templ.newTransformer(); for (String item: groups){ item = item.replaceAll(" ", "-").toLowerCase(); result.setOutputStream(new FileOutputStream(path+item+".html")); transf.clearParameters(); transf.setParameter("group", item); transf.transform(xmlSource, result); } } catch (TransformerConfigurationException e) { throw new SinkException(e.getMessage()); } catch (TransformerException e) { throw new SinkException(e.getMessage()); } But on second iteration I have an exception ERROR: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Read error Cann't understand what is the reason?

    Read the article

  • Exception and Inheritance in JAVA

    - by user1759950
    Suppose we have this problem public class Father{ public void method1(){...} } public class Child1 extends Father{ public void method1() throws Exception{ super.method1(); ... } } Child1 extends Father and override method1 but given implementation Child1.method1 now throws a exception, this wont compile as override method can't throw new exceptions. What is the best solution? Propagate the required exception to the Father.. to me this is against encapsulation, inheritance and general OOP ( the father potentially throw and exception that will never happen ) Use a RuntimeException instead? This solution wont propagate the Exception to the father but I read In Oracle docs and others sources states class of exceptions should be used when "Client code cannot do anything" this is not that case, this exception will b useful to recover blablabla ( why is wrong to use RuntimeException instead? ) Other.. thanks, Federico

    Read the article

  • C++ std::equal -- rationale behind not testing for the 2 ranges having equal size?

    - by ShaChris23
    I just wrote some code to test the behavior of std::equal, and came away surprised: int main() { try { std::list<int> lst1; std::list<int> lst2; if(!std::equal(lst1.begin(), lst1.end(), lst2.begin())) throw std::logic_error("Error: 2 empty lists should always be equal"); lst2.push_back(5); if(std::equal(lst1.begin(), lst1.end(), lst2.begin())) throw std::logic_error("Error: comparing 2 lists where one is not empty should not be equal"); } catch(std::exception& e) { std::cerr << e.what(); } } The output (a surprise to me): Error: comparing 2 lists where one is not empty should not be equal Observation: why is it the std::equal does not first check if the 2 containers have the same size() ? Was there a legitimate reason?

    Read the article

  • Multithreaded SDL error in C++

    - by wyatt
    I'm building a program in C++, using SDL, and am occasionally receiving this error: * glibc detected * ./assistant: double free or corruption (!prev) It's difficult to replicate, so I can't find exactly what's causing it, but I just added a second thread to the program, and neither thread run on its own seems to cause the error. The threads don't share any variables, though they both run the functions SDL_BlitSurface and SDL_Flip. Could running these concurrently throw up such an error, or am I barking up the wrong tree? If this is the cause, should I simply throw a mutex around all SDL calls? Thanks

    Read the article

  • returning null or throwing an exception?

    - by MoKi
    I have the following types: typedef QPair < QTime , QTime > CalculatedTimeSlotRange; typedef QList < CalculatedTimeSlotRange > CalculatedTimeSlotRangeList; typedef QHash < quint8 , CalculatedTimeSlotRangeList > TimeSlotsTable; I have a function like the following: const CalculatedTimeSlotRangeList* TimeSlots::getCalculatedTimeSlotRangeList(const quint8 id) const { QHashIterator<quint8,CalculatedTimeSlotRangeList> it(mTimeSlotsTable); while (it.hasNext()) { it.next(); if(it.key() == id) { return &it.value(); } } return NULL; } as you can see my function returns a null if it fails to find a key that matches id. Is this correct? or should I just throw an exception if the key does not exist? how should i throw an exception for this situation?

    Read the article

  • HashMap "WriteOnce" Implementation .. need help

    - by JavaNewbie
    import java.util.*; public class HashMapExample { public static class WriteOnceMap<K, V> extends HashMap<K, V> { public V put(K key, V value) { /* WriteOnceMap is a map that does not allow changing value for a particular key. It means that put() method should throw IllegalArgumentException if the key is already assosiated with some value in the map. Please implement this method to conform to the above description of WriteOnceMap. */ } public void putAll(Map<? extends K, ? extends V> m) { /* Pleaase implement this method to conform to the description of WriteOnceMap above. It should either (1) copy all of the mappings from the specified map to this map or (2) throw IllegalArgumentException and leave this map intact if the parameter already contains some keys from this map. */ } } }

    Read the article

  • Throwing out of range exception in C++

    - by Shinka
    This code works; int at(int index) { if(index < 1 || index >= size) throw 0; return x[index]; } Yet this doesn't int at(int index) { if(index < 1 || index >= size) throw std::out_of_range; return x[index]; } I get the error "expected primary expression before ';'". Now... it surprises me because I know std::out_of_range exists and I have #include <stdexcept>

    Read the article

  • Distribution of many small classes

    - by Moo-Juice
    Hi All, I have a base class called EventArgs. Derived from this are many, many specializations that represent event arguments for a particular kind of event. Consumers of these events may need some, many, or very few of these argument classes. My question is, would you provide a header file for each type (e.g, 50+ header files for the varying ones), would you try to group them in to families and have a 'common' header file for those, or would you throw caution to the window and throw them in to one easy-of-use header file that can just be included? Another approach might be to have 50 header files, and then I could introduce some "family" header files that included particular ones. Not sure about the naming conventions for these kinds of things so it is obvious what is where. I know there may not be a hard and fast rule, but wondering what other developers have done when they find themselves writing many little classes. Thanks in advance.

    Read the article

  • Converting C# class to JavaScript

    - by AgileMeansDoAsLittleAsPossible
    Take a look at this basic class: namespace AcmeWeb { public string FirstName { get; set; } public class Person { public Person(string firstName, string lastName) { if (String.IsNullOrEmpty(firstName)) { throw new ArgumentNullException(firstName); } this.FirstName = firstName; } } } What's the best translation of this into JavaScript? This is what I'm thinking: (function(namespace) { namespace.Person = function(firstName, lastName) { // Constructor (function() { if (!firstName) { throw "'firstName' argument cannot be null or empty"; } })(); // Private memberts var _ = { firstName: firstName }; // Public members this.firstName = function(value) { if (typeof(value) === "undefined") { return _.firstName; } else { _.firstName = value; return this; } }; }; })(AcmeWeb);

    Read the article

  • What does "Only catch exceptions you can handle" really mean?

    - by KyleLib
    I'm tasked with writing an Exception Handling Strategy and Guidelines document for a .NET/C# project I'm working on. I'm having a tough go at it. There's plenty of information available for how/when to throw, catch, wrap exceptions, but I'm looking for describing what sorts of things should go on inside the catch block short of wrapping and throwing the exception. try { DoSomethingNotNice(); } catch (ExceptionICanHandle ex) { //Looking for examples of what people are doing in catch blocks //other than throw or wrapping the exception, and throwing. } Thanks in advance

    Read the article

  • How to validate referral support implemented for Active Dircetory server?

    - by user146560
    Please suggest me some utility or application, using which i want to test referral settings done. I want to test cross forest referenced reference. Among two DNS say 1 firstDNS.com user([email protected]) 2 SecondDNS.com user([email protected]) Below java code written to test active directory server setting. public void authenticateUser(String user, String password, String domain) throws AuthenticationException, NamingException { List<String> ldapServers = findLDAPServersInWindowsDomain("first.com"); if (ldapServers.isEmpty()) throw new NamingException("Can't locate an LDAP server (try nslookup type=SRV _ldap._tcp." + "first.com"+ ")"); Hashtable<String, String> props = new Hashtable<String, String>(); String principalName = "testUserFirst"+ "@" + "First.com"; props.put(Context.SECURITY_PRINCIPAL, principalName); props.put(Context.SECURITY_CREDENTIALS, password); props.put(Context.REFERRAL,"follow"); //props.put(Context.SECURITY_AUTHENTICATION, "anonymous"); Integer count = 0; for (String ldapServer : ldapServers) { try { count++; DirContext ctx = LdapCtxFactory.getLdapCtxInstance("ldap://" + ldapServer, props); SearchControls searchCtls = new SearchControls(); //Specify the attributes to return String returnedAtts[]={"sn","givenName","mail"}; searchCtls.setReturningAttributes(returnedAtts); //Specify the search scope searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE); //specify the LDAP search filter String searchFilter = "(&(objectClass=user)(sAMAccountName=" testUserSecond)(userPassword=usertest@3))"; //Specify the Base for the search String searchBase = "DC=second,DC=com"; //initialize counter to total the results int totalResults = 0; // Search for objects using the filter NamingEnumeration<SearchResult> answer = ctx.search(searchBase, searchFilter, searchCtls); return; } catch (CommunicationException e) { // this is what'll happen if one of the domain controllers is unreachable if (count.equals(ldapServers.size())) { // we've got no more servers to try, so throw the CommunicationException to indicate that we failed to reach an LDAP server throw e; } } } } private List<String> findLDAPServersInWindowsDomain(String domain) throws NamingException { List<String> servers = new ArrayList<String>(); Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); env.put("java.naming.provider.url", "dns://"); DirContext ctx = new InitialDirContext(env); Attributes attributes = ctx.getAttributes("_ldap._tcp." + domain, new String[] { "SRV" }); // that's how Windows domain controllers are registered in DNS Attribute a = attributes.get("SRV"); for (int i = 0; i < a.size(); i++) { String srvRecord = a.get(i).toString(); // each SRV record is in the format "0 100 389 dc1.company.com." // priority weight port server (space separated) servers.add(srvRecord.split(" ")[3]); } ctx.close(); return servers; }

    Read the article

  • MySQL Server 5.6 defaults changes

    - by user12626240
    We're improving the MySQL Server defaults, as announced by Tomas Ulin at MySQL Connect. Here's what we're changing:  Setting  Old  New  Notes back_log  50  50 + ( max_connections / 5 ) capped at 900 binlog_checksum  off  CRC32  New variable in 5.6 binlog_row_event_max_size  1k  8k flush_time  1800  Windows changes from 1800 to 0  Was already 0 on other platforms host_cache_size  128  128 + 1 for each of the first 500 max_connections + 1 for every 20 max_connections over 500, capped at 2000  New variable in 5.6 innodb_autoextend_increment  8  64  Now affects *.ibd files. 64 is 64 megabytes innodb_buffer_pool_instances  0  8. On 32 bit Windows only, if innodb_buffer_pool_size is greater than 1300M, default is innodb_buffer_pool_size / 128M innodb_concurrency_tickets  500  5000 innodb_file_per_table  off  on innodb_log_file_size  5M  48M  InnoDB will always change size to match my.cnf value. Also see innodb_log_compressed_pages and binlog_row_image innodb_old_blocks_time 0  1000 1 second innodb_open_files  300  300; if innodb_file_per_table is ON, higher of table_open_cache or 300 innodb_purge_batch_size  20  300 innodb_purge_threads  0  1 innodb_stats_on_metadata  on  off join_buffer_size 128k  256k max_allowed_packet  1M  4M max_connect_errors  10  100 open_files_limit  0  5000  See note 1 query_cache_size  0  1M query_cache_type  on/1  off/0 sort_buffer_size  2M  256k sql_mode  none  NO_ENGINE_SUBSTITUTION  See later post about default my.cnf for STRICT_TRANS_TABLES sync_master_info  0  10000  Recommend: master_info_repository=table sync_relay_log  0  10000 sync_relay_log_info  0  10000  Recommend: relay_log_info_repository=table. Also see Replication Relay and Status Logs table_definition_cache  400  400 + table_open_cache / 2, capped at 2000 table_open_cache  400  2000   Also see table_open_cache_instances thread_cache_size  0  8 + max_connections/100, capped at 100 Note 1: In 5.5 there was already a rule to make open_files_limit 10 + max_connections + table_cache_size * 2 if that was higher than the user-specified value. Now uses the higher of that and (5000 or what you specify). We are also adding a new default my.cnf file and guided instructions on the key settings to adjust. More on this in a later post. We're also providing a page with suggestions for settings to improve backwards compatibility. The old example files like my-huge.cnf are obsolete. Some of the improvements are present from 5.6.6 and the rest are coming. These are ideas, and until they are in an official GA release, they are subject to change. As part of this work I reviewed every old server setting plus many hundreds of emails of feedback and testing results from inside and outside Oracle's MySQL Support team and the many excellent blog entries and comments from others over the years, including from many MySQL Gurus out there, like Baron, Sheeri, Ronald, Schlomi, Giuseppe and Mark Callaghan. With these changes we're trying to make it easier to set up the server by adjusting only a few settings that will cause others to be set. This happens only at server startup and only applies to variables where you haven't set a value. You'll see a similar approach used for the Performance Schema. The Gurus don't need this but for many newcomers the defaults will be very useful. Possibly the most unusual change is the way we vary the setting for innodb_buffer_pool_instances for 32-bit Windows. This is because we've found that DLLs with specified load addresses often fragment the limited four gigabyte 32-bit address space and make it impossible to allocate more than about 1300 megabytes of contiguous address space for the InnoDB buffer pool. The smaller requests for many pools are more likely to succeed. If you change the value of innodb_log_file_size in my.cnf you will see a message like this in the error log file at the next restart, instead of the old error message: [Warning] InnoDB: Resizing redo log from 2*64 to 5*128 pages, LSN=5735153 One of the biggest challenges for the defaults is the millions of installations on a huge range of systems, from point of sale terminals and routers though shared hosting or end user systems and on to major servers with lots of CPU cores, hundreds of gigabytes of RAM and terabytes of fast disk space. Our past defaults were for the smaller systems and these change that to larger shared hosting or shared end user systems, still with a bias towards the smaller end. There is a bias in favour of OLTP workloads, so reporting systems may need more changes. Where there is a conflict between the best settings for benchmarks and normal use, we've favoured production, not benchmarks. We're very interested in your feedback, comments and suggestions.

    Read the article

  • SSIS code smell – Unused columns in the dataflow

    - by jamiet
    A code smell is defined on Wikipedia as being a “symptom in the source code of a program that possibly indicates a deeper problem”. It’s a term commonly used by our code-writing brethren to describe sub-optimal code but I think the term can be applied equally well to SSIS packages too as I shall now explain One of my pet hates about SSIS development is packages that throw warnings of the form: The output column "ColumnName" (1358) on output "OLE DB Source Output" (1289) and component "OLE_SRC Name" (1279) is not subsequently used in the Data Flow task. Removing this unused output column can increase Data Flow task performance.  The warning is fairly self-explanatory – any column that appears in the data flow but doesn’t get used will throw this warning when the data flow is executed. Its not the negligible performance degradation that they cause that bothers me though, it’s the clutter that they cause in your log file/table. Take a look at the following screenshot if you don’t believe me: There are 231409 such warnings in the system that I took this screenshot from, that is 231409 log records that should not be there. The most infuriating thing about this warning is that it is so easily avoidable; eliminating such columns is a very quick and easy thing to do in the SSIS Designer. The only problem I see is that the warnings don’t occur until you execute the package – it would be preferable for the designer to have an unobtrusive way of informing you of them as well. Anyway, I digress… I consider such warnings to be a code smell because, to me, they’re symptomatic of a lack of due care and attention; a lack of developer discipline if you will. What other code smells can you think of when building SSIS packages? If I get a good list in the comments maybe I’ll compile them into a later blog post. @Jamiet Share this post: email it! | bookmark it! | digg it! | reddit! | kick it! | live it!

    Read the article

  • T-SQL Tuesday #005: Creating SSMS Custom Reports

    - by Mike C
    This is my contribution to the T-SQL Tuesday blog party, started by Adam Machanic and hosted this month by Aaron Nelson . Aaron announced this month's topic is "reporting" so I figured I'd throw a blog up on a reporting topic I've been interested in for a while -- namely creating custom reports in SSMS. Creating SSMS custom reports isn't difficult, but like most technical work it's very detailed with a lot of little steps involved. So this post is a little longer than usual and includes a lot of...(read more)

    Read the article

  • T-SQL Tuesday #005: Creating SSMS Custom Reports

    - by Mike C
    This is my contribution to the T-SQL Tuesday blog party, started by Adam Machanic and hosted this month by Aaron Nelson . Aaron announced this month's topic is "reporting" so I figured I'd throw a blog up on a reporting topic I've been interested in for a while -- namely creating custom reports in SSMS. Creating SSMS custom reports isn't difficult, but like most technical work it's very detailed with a lot of little steps involved. So this post is a little longer than usual and includes a lot of...(read more)

    Read the article

  • ASP.NET Web API - Screencast series Part 2: Getting Data

    - by Jon Galloway
    We're continuing a six part series on ASP.NET Web API that accompanies the getting started screencast series. This is an introductory screencast series that walks through from File / New Project to some more advanced scenarios like Custom Validation and Authorization. The screencast videos are all short (3-5 minutes) and the sample code for the series is both available for download and browsable online. I did the screencasts, but the samples were written by the ASP.NET Web API team. In Part 1 we looked at what ASP.NET Web API is, why you'd care, did the File / New Project thing, and did some basic HTTP testing using browser F12 developer tools. This second screencast starts to build out the Comments example - a JSON API that's accessed via jQuery. This sample uses a simple in-memory repository. At this early stage, the GET /api/values/ just returns an IEnumerable<Comment>. In part 4 we'll add on paging and filtering, and it gets more interesting.   The get by id (e.g. GET /api/values/5) case is a little more interesting. The method just returns a Comment if the Comment ID is valid, but if it's not found we throw an HttpResponseException with the correct HTTP status code (HTTP 404 Not Found). This is an important thing to get - HTTP defines common response status codes, so there's no need to implement any custom messaging here - we tell the requestor that the resource the requested wasn't there.  public Comment GetComment(int id) { Comment comment; if (!repository.TryGet(id, out comment)) throw new HttpResponseException(HttpStatusCode.NotFound); return comment; } This is great because it's standard, and any client should know how to handle it. There's no need to invent custom messaging here, and we can talk to any client that understands HTTP - not just jQuery, and not just browsers. But it's crazy easy to consume an HTTP API that returns JSON via jQuery. The example uses Knockout to bind the JSON values to HTML elements, but the thing to notice is that calling into this /api/coments is really simple, and the return from the $.get() method is just JSON data, which is really easy to work with in JavaScript (since JSON stands for JavaScript Object Notation and is the native serialization format in Javascript). $(function() { $("#getComments").click(function () { // We're using a Knockout model. This clears out the existing comments. viewModel.comments([]); $.get('/api/comments', function (data) { // Update the Knockout model (and thus the UI) with the comments received back // from the Web API call. viewModel.comments(data); }); }); }); That's it! Easy, huh? In Part 3, we'll start modifying data on the server using POST and DELETE.

    Read the article

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