{"id":730,"date":"2012-06-03T14:35:27","date_gmt":"2012-06-03T14:35:27","guid":{"rendered":"https:\/\/theextremewebdesigns.com\/blog\/?p=730"},"modified":"2012-06-03T14:35:27","modified_gmt":"2012-06-03T14:35:27","slug":"jquery-ajax-error-handling-function","status":"publish","type":"post","link":"https:\/\/theextremewebdesigns.com\/blog\/jquery-ajax-error-handling-function\/","title":{"rendered":"jQuery Ajax Error Handling Function"},"content":{"rendered":"<p>Have you ever wondered what went wrong when working on jQuery Ajax operations? It could be a painful experience to try to find out the bugs or the root of the problem when you don&#8217;t know what exactly is the problem. In this article, I am going to share with you a simple way of using <em><strong>Ajax Error Handling Function in jQuery<\/strong><\/em>.<!--more--><\/p>\n<h2>Examples of using Ajax Error Handling Function in jQuery<\/h2>\n<p>Consider the following example code below:<\/p>\n<pre class=\"lang:js decode:true\">$.ajax({\ntype: \"POST\",\nurl: \"ajax_page.php\",\nsuccess: function(data, status, xhr) {\n\/\/ perform operations on success\nalert('Success');\n},\nerror: function(xhr, status, error) {\n\/\/ perform operations on error\nalert(xhr.responseText);\n}\n});<\/pre>\n<p>In the above code, note the usage of \u00a0<strong>&#8220;xhr.responseText&#8221;<\/strong>. We are alerting (echoing) the error we receive in the jQuery Ajax operations. Just comment it out or remove it, when moving the files to production.<\/p>\n<h5>That&#8217;s it!<\/h5>\n<p>Do you know of any other ways to write\u00a0<em><strong>jQuery Ajax Error Handling Function<\/strong><\/em>? Feel free to share by commenting below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you ever wondered what went wrong when working on jQuery Ajax operations? It could be a painful experience to try to find out the bugs or the root of the problem when you don&#8217;t know what exactly is the problem. In this article, I am going to share with you a simple way of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":395,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[21],"tags":[41],"class_list":["post-730","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","tag-jquery-tips"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/paBnQX-bM","jetpack_sharing_enabled":true,"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/730","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/comments?post=730"}],"version-history":[{"count":0,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/posts\/730\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/media?parent=730"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/categories?post=730"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theextremewebdesigns.com\/blog\/wp-json\/wp\/v2\/tags?post=730"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}