{"id":33,"date":"2007-06-22T20:11:13","date_gmt":"2007-06-22T14:41:13","guid":{"rendered":"http:\/\/www.bin-co.com\/blog\/2007\/06\/successerror-design-pattern-for-ajax\/"},"modified":"2007-06-22T20:11:13","modified_gmt":"2007-06-22T14:41:13","slug":"successerror-design-pattern-for-ajax","status":"publish","type":"post","link":"https:\/\/www.bin-co.com\/blog\/2007\/06\/successerror-design-pattern-for-ajax\/","title":{"rendered":"Success\/Error Design Pattern For Ajax"},"content":{"rendered":"<p class=\"intro\">&#8216;Success\/Error&#8217; design pattern for Ajax requests is a <abbr title=\"JavaScript Object Notation\">JSON<\/abbr> encoded string in a specific format &#8211; each response has a minimum of two elements in it &#8211; ie &#8216;success&#8217; and &#8216;error&#8217; &#8211; like this&#8230;<\/p>\n<pre><code class=\"javascript\">{\n\"success\":\"Task done successfully\",\n\"error\":false\n}<\/code><\/pre>\n<p>OR<\/p>\n<pre><code class=\"javascript\">{\n\"success\":false,\n\"error\":\"Database Connection Error!\"\n}<\/code><\/pre>\n<p>This method is used extensivly in <a href=\"http:\/\/www.bin-co.com\/blog\/2007\/05\/what-i-learned-from-nexty\/\">Nexty<\/a>. Almost all Ajax response in Nexty ares in this format.<\/p>\n<p>Since this is in the JavaScript domain, I thougt it might be better to pubish the details in my <a href=\"http:\/\/www.openjs.com\/\">OpenJS site<\/a>. Read more about <a href=\"http:\/\/www.openjs.com\/articles\/ajax\/success_error_design_pattern.php\">Success\/Error Design Pattern For Ajax<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>&#8216;Success\/Error&#8217; design pattern for Ajax requests is a JSON encoded string in a specific format &#8211; each response has a minimum of two elements in <a class=\"mh-excerpt-more\" href=\"https:\/\/www.bin-co.com\/blog\/2007\/06\/successerror-design-pattern-for-ajax\/\" title=\"Success\/Error Design Pattern For Ajax\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,15,30],"tags":[40,90,144,155,203],"class_list":["post-33","post","type-post","status-publish","format-standard","hentry","category-ajax","category-javascript","category-web-development","tag-ajax","tag-design","tag-iis","tag-javascript","tag-pattern"],"_links":{"self":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":0,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}