Jquery Ajax submit form upload

jQuery Function Code jQuery(document).on(‘click’, ‘.button-custom’, function(){ box1 = new ajaxLoader(“html”); type_submit = jQuery(this).attr(‘id’); var data = new FormData(); data.append( ‘type_submit’, type_submit); data.append( ‘text_1’, jQuery(‘.text_1’).val()); data.append( ‘text_2’, jQuery(‘.text_2’).val()); data.append( ‘text_3’, jQuery(‘#text_3’).val()); data.append( ‘id’, jQuery(‘.hcp_info_id’).val()); data.append( ‘fileToUpload_1’, jQuery(‘input[name=fileToUpload_1]’)[0].files[0]); // data.append( ‘fileToUpload_2’, jQuery(‘input[name=fileToUpload_2]’)[0].files[0]); data.append(“action”, “updateFormDraft”); jQuery.ajax({ type: “POST”, url: ajaxurl, contentType: false, processData: false, data: data, success: function(data){… Continue reading Jquery Ajax submit form upload


Alternate to array_column function php if not support

You can add your code this function to use if (! function_exists(‘array_column’)) { function array_column(array $input, $columnKey, $indexKey = null) { $array = array(); foreach ($input as $value) { if ( ! isset($value[$columnKey])) { trigger_error(“Key \”$columnKey\” does not exist in array”); return false; } if (is_null($indexKey)) { $array[] = $value[$columnKey]; } else { if (… Continue reading Alternate to array_column function php if not support


count of duplicate elements in an array in php

You can adopt this trick; map each item of the array (which is an array itself) to its respective [‘lid’] member and then use array_count_value() to do the counting for you. array_count_values(array_map(function($item) { return $item[‘lid’]; }, $arr); Plus, it’s a one-liner, thus adding to elite hacker status. Update Since 5.5 you can shorten it to:… Continue reading count of duplicate elements in an array in php


Send email from local

Edit fileĀ /etc/ssmtp/ssmtp.conf with content hostname=YourComputerHostName UseTLS=YES UseSTARTTLS=YES AuthPass=passwordofmyaccount AuthMethod=LOGIN FromLineOverride=YES