Skip to main content

Posts

Showing posts from 2019

Loading gif while waiting for AJAX response without any button trigger

When there is no trigger for loading gif we can use setTimeout dunction to display image < img src = "loading.GIF" id = "img" style = "display:none" / > < script > setTimeout( function (){$( '#img' ).show();}, 30 ); $.ajax({ type : 'POST' , url : ' ajaxfile.php' , data : {id : 123 }, success : function (response) { $( '#img' ).hide() }, error : function (response,status) { alert( 'Error' ); } }); < /script>

Check curl status

We can check curl status as below $curl = curl_init(); curl_setopt($curl,CURLOPT_URL,'https://esoftsolutions4u.blogspot.com'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($curl); $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); If $http_status = 200,then we have correct response. If ($http_status ="" || $http_status ="failed" ) then we have failed response or some error in the response.

Convert HTML to PDF using mPDF library

PDF is format of file to share .Here is code for converting html to PDF using mpdf library (PHP library). //include library path include('mpdf/mpdf.php'); $mpdf=new mPDF('c','A4','','' , 0 , 0 , 0 , 0 , 0 , 0); $mpdf->SetDisplayMode('fullpage'); $mpdf->list_indent_first_level = 0; $mpdf->WriteHTML('<html><head></head><body><h2>Welecome to HTML to PDF </h2></body></html>'); //save the file put which location you need folder/filename $mpdf->Output('test.pdf', 'F'); You can download the library from GitHub. Extract it and paste into your (project folder).

Curl retrieval of page or url

Simple way of retrieving data from an URL  using CURL $curl = curl_init(); curl_setopt($curl,CURLOPT_URL,'https://esoftsolutions4u.blogspot.com'); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($curl); $http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl);

Easily search and use the commands that you had used in the past

Imagine a situation where you used a long command couple of minutes/hours ago and you have to use it again. Problem is that you cannot remember the exact command anymore. Reverse search is your savior here. You can search for the command in the history using a search term. Just use the keys ctrl+r to initiate reverse search and type some part of the command. It will look up into the history and will show you the commands that matches the search term. ctrl+r search_term By default, it will show just one result. To see more results matching your search term, you will have to use ctrl+r again and again. To quit reverse search, just use Ctrl+C.