{"id":41456,"date":"2016-02-22T14:35:24","date_gmt":"2016-02-22T14:35:24","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=41456"},"modified":"2016-02-22T14:35:24","modified_gmt":"2016-02-22T14:35:24","slug":"hide-header-and-footer-html-in-ajax-response-using-front-controller","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/","title":{"rendered":"Hide Header and Footer HTML in AJAX response using Front Controller"},"content":{"rendered":"<p>When we have to use Ajax in Prestashop front development, we have to create a file where we can perform the process. Generally, we have created an ajax folder and in that folder, we create and file ajax.php for our ajax processing, in this file we have to load Prestashop Classes by including config.inc file.<\/p>\n<p>But instead of this, we can create a PrestaShop front controller and use this front controller for ajax processing.<\/p>\n<p>Simply create a Front controller if not exist OR use the existing controller and process your Ajax on the same.<\/p>\n<p>Prestashop front controller always has the HTML of Header and Footer, So while ajax response, we have to hide them.<\/p>\n<p>If we are using the existing Front Controller where the other operation also performs, We have to create a condition in which we can hide the header and footer<code><\/code><\/p>\n<p>Define display_header and display_footer variable false in Front Controller file init function<\/p>\n<pre class=\"brush:php\">public function init()\r\n{\r\n    if (Tools::getValue('ajax')) {\r\n        $this-&gt;display_header = false;\r\n        $this-&gt;display_footer = false;\r\n    }\r\n}<\/pre>\n<p>Otherwise, simply define init function like this,<\/p>\n<pre class=\"brush:php\">public function init()\r\n{\r\n    $this-&gt;display_header = false;\r\n    $this-&gt;display_footer = false;\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>When we have to use Ajax in Prestashop front development, we have to create a file where we can perform the process. Generally, we have created an ajax folder and in that folder, we create and file ajax.php for our ajax processing, in this file we have to load Prestashop Classes by including config.inc file. <a href=\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,209,1],"tags":[2776,2065,985],"class_list":["post-41456","post","type-post","status-publish","format-standard","hentry","category-php","category-prestashop","category-uncategorized","tag-front-controller","tag-prestashop","tag-prestashop-ajax"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hide Header and Footer HTML in AJAX response using Front Controller - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hide Header and Footer HTML in AJAX response using Front Controller - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"When we have to use Ajax in Prestashop front development, we have to create a file where we can perform the process. Generally, we have created an ajax folder and in that folder, we create and file ajax.php for our ajax processing, in this file we have to load Prestashop Classes by including config.inc file. [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-22T14:35:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Dheeraj Sharma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/dks295\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dheeraj Sharma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/\"},\"author\":{\"name\":\"Dheeraj Sharma\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/a5f3da471d7cb80626232ba698343f6a\"},\"headline\":\"Hide Header and Footer HTML in AJAX response using Front Controller\",\"datePublished\":\"2016-02-22T14:35:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/\"},\"wordCount\":177,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"front controller\",\"prestashop\",\"prestashop Ajax\"],\"articleSection\":[\"php\",\"prestashop\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/\",\"url\":\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/\",\"name\":\"Hide Header and Footer HTML in AJAX response using Front Controller - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2016-02-22T14:35:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hide Header and Footer HTML in AJAX response using Front Controller\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/a5f3da471d7cb80626232ba698343f6a\",\"name\":\"Dheeraj Sharma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/95497c38ac4e669f4042d356b0397dce21d1a90688eddd87cfde8ff771c40041?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/95497c38ac4e669f4042d356b0397dce21d1a90688eddd87cfde8ff771c40041?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Dheeraj Sharma\"},\"sameAs\":[\"http:\/\/webkul.com\",\"https:\/\/x.com\/https:\/\/twitter.com\/dks295\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/dheeraj\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hide Header and Footer HTML in AJAX response using Front Controller - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/","og_locale":"en_US","og_type":"article","og_title":"Hide Header and Footer HTML in AJAX response using Front Controller - Webkul Blog","og_description":"When we have to use Ajax in Prestashop front development, we have to create a file where we can perform the process. Generally, we have created an ajax folder and in that folder, we create and file ajax.php for our ajax processing, in this file we have to load Prestashop Classes by including config.inc file. [...]","og_url":"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-02-22T14:35:24+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Dheeraj Sharma","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/dks295","twitter_site":"@webkul","twitter_misc":{"Written by":"Dheeraj Sharma","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/"},"author":{"name":"Dheeraj Sharma","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/a5f3da471d7cb80626232ba698343f6a"},"headline":"Hide Header and Footer HTML in AJAX response using Front Controller","datePublished":"2016-02-22T14:35:24+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/"},"wordCount":177,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["front controller","prestashop","prestashop Ajax"],"articleSection":["php","prestashop"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/","url":"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/","name":"Hide Header and Footer HTML in AJAX response using Front Controller - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2016-02-22T14:35:24+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/hide-header-and-footer-html-in-ajax-response-using-front-controller\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Hide Header and Footer HTML in AJAX response using Front Controller"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/a5f3da471d7cb80626232ba698343f6a","name":"Dheeraj Sharma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/95497c38ac4e669f4042d356b0397dce21d1a90688eddd87cfde8ff771c40041?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/95497c38ac4e669f4042d356b0397dce21d1a90688eddd87cfde8ff771c40041?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Dheeraj Sharma"},"sameAs":["http:\/\/webkul.com","https:\/\/x.com\/https:\/\/twitter.com\/dks295"],"url":"https:\/\/webkul.com\/blog\/author\/dheeraj\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/41456","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=41456"}],"version-history":[{"count":10,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/41456\/revisions"}],"predecessor-version":[{"id":41564,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/41456\/revisions\/41564"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=41456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=41456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=41456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}