Magento 2: Return JSON, XML, HTML & Raw Text Data Response from Controller

This article shows how you can return JSON data, XML data, HTML data, or Raw Text data from any Controller class in Magento 2. Generally, in the Magento2 controller’s execute() function, we see the redirect or forwarding call which redirects to the specified URL page. However, we might sometime need to return the JSON format … Read more

PHP: Scrap Web Page Content using Simple HTML DOM Parser

This article shows how you can scrap or fetch any webpage’s HTML content/data in PHP. We will use Simple HTML DOM Parser to scrap webpage content. You can download it from here: PHP Simple HTML DOM Parser – Sourceforge You need to download the HTML DOM Parser from sourceforge and include simple_html_dom_parser.php in your PHP … Read more

Google AppScript: Create Form using HTML, Publish Form as WebApp & Show data from Spreadsheet

This article shows: 1) How to create Google Form using standalone HTML file 2) Fetch data from Google Spreadsheet and populate Select box of the HTML Form 3) Populate second select box based on the value selected from first select box 4) Show result data from spreadsheet on form submit Basically, we have a spreadsheet … Read more

Google AppScript: Create Form using HTML, Publish Form as WebApp & Email Response

This article shows: 1) How to create Google Form using standalone HTML file 2) Email form submitted data to any particular email address Create HTML file We create a Form in a new HTML File. Go to http://script.google.com Go to File -> New -> Html file Type the name of the file, e.g. form.html Write … Read more

Javascript: How to Submit form and Change form action?

This article will show you how to submit form and change form action using javascript. This is a very simple trick but it’s very useful and frequently used. Submit Form using Javascript HTML form <form name="myForm" action="http://google.com" method="get"> Search: <input type="text" name="q" /> <button onclick="javascript: submitForm()">Search</button> </form> Javascript function function submitForm() { document.myForm.submit(); } Change … Read more

Javascript: Show/Hide HTML elements

Here, I will be demonstrating on showing or hiding a div when a link is clicked. I have done this with Javascript and CSS. I have called showHideDiv() Js function when the link is clicked. The display of the div where content is present, is visible or hidden on each click. For this, CSS styling … Read more

Javascript: Add Remove HTML elements

You can add html elements dynamically with Javascript. In this article, I will show you how to do so. I have created two Javascript functions. One for creating html elements and the other for removing them. In my html elements, I have created ‘li’ and ‘strong’ elements inside ‘div’. The div id is ‘summary’. I … Read more

PHP: How to get (view) html source code of a website

Here is the PHP code to fetch the html source code of any website specified. fopen function is used to open the website URL. stream_get_contents is used to read the opened URL. The fetched code is displayed inside a textarea. $domain = 'http://example.com'; $handle = fopen($domain, 'r'); $content = stream_get_contents($handle); /** // alternative to stream_get_contents … Read more