How to submit a form with jquery ajax and with HTML 5 Validation

Jquery ajax as well as html 5 validations are one of the most important features of web development. Both of them makes the tasks of developers so damn easy. Some of you might ran into issues while using both of them simultaneously , especially with jquery click for triggering the form(the validation may freak out if we use click).  Actually the solution is simple, we just need to use the jquery submit so that the ajax will get triggered only after successful form validation. The form gets submitted via ajax to contact.php and success and errors are handled inside the jquery ajax. The form is set up in html 5, and the validations will be in action on form submit.




Name:

Email:


If you don’t know much about about jquery ajax form submissions ,have look at this clean tutorial about Jquery ajax -php and form submissions

Demo

Download Source

How to display adsense(advertisements) below first 3 (N) posts in wordpress only

Most or majority  of the wordpress bloggers use adsense (or advertisements) below posts. And in the home page (where we can display 3 ad units (adsense)  in total, each one below posts so as to display ads below the first 3 posts ). But the real issue is that the javascript code for the ads gets called again inside the wordpress loop and blank space will be shown there from the 4th posts onwards.

Normal Adsene below wordpress post title
Normal Adsene below wordpress post title
Adsense below the 4th post
Adsense below the 4th post

The $wp_query->current_post inside the wordpress will help you to fix this issues.  It will get the count of the current loop executed in the wordpress. And if the loop (post) is the 4th one , we can block the script from being run.

  
      

  current_post < 3) : ?>
  
Advertisements

Remember that the wordpress loop count start with zero, you can limit the number of ad units displayed to 1 or 2 by changing the $wp_query->current_post < 3 as per you wish
 

4 Types of Video ads you can create for your Product

Video advertisment are now the most trendy method to promote your product. Doesnt have any idea about creating and ad for your product? How can you create a unique video ad that can attract customers? This article will help you.

First of all you should identify the character of your product and make the advertisment for the peculiar product behavior.
Video ads can be of three types

Type 1 (Video ad have zero relation with the product )

In this type, the ad content doesn’t have much(or zero) relation to the product. The best example is Krack and Jack of
the advertisement of the KrackJack biscuits. Krack and Jack does something funny and the whole 1 min ad is about hilarious or funny adventures of both of them.So what did work for the product ultimately?
What worked was that, the producers gave life to the biscuit KrackJack through the characters Krack and Jack. People did switch on their tv to watch their ads alone. It was that funny. And when the ad ends, they just show the product (biscuits) in a glance. Have a look at this old KrackJack ad

Type 2 (Ad do have a relation to the Product, but the ad is illogical and funny)

In this type, the advertisement has true relation to the product. But rather than focusing on the pros of the product, it makes the audience think. The ad may be illogical,but in the end it makes the viewer think about the possibility. Fevicol is the best example of such kind of such kind of ads. Have you seen the fevicol hen ad? The egg hatched by the hen doesn’t breaks (Its even hammered). This part of the ad creates curiosity in the mind of audience as no one haven’t ever heard about such and unbreakable egg. In the end we can see that the hen was having its food in an old fevicol gum tin( and that’s why its eggs didn’t break).

If you think about this ad, you can easily figure out that its illogical, but the idea was interesting right? And that lead to the success of the advertisement.


Why did fevicol go for that illogical idea?

If you think closer you can figure out the reason. Unlike Iphone 5 which do have lots of features and functionalities (I’ve mentioned this in type 3) fevicol doesnt have something to project except its quality and strength. Lets take the example of the iphone ad,they need to explain about all their key features like( display, speed, camera so and so) in a limited time. No one cares about the color or look of a gum, so in the end of the day fevicol only
need to show how strong their gum is. Even though illogical, the hen ad does this purpose perfectly. So when it comes to products like gums, its all about branding it. The most popular and branded product wins the game.
Another good example is the Axe advertisement. The interesting part when working with these kind of ads is that the imagination limit is the sky. Do you think all the ladies will come after you,just because of using AXE? The ad is not practical in that sense, but the impacts made by these kinds of ads are really high.

The Axe Effect Ad

Type 3 (Exploring the features and pros of the product).

Type 3 ads focus on the features and fuctionalities of the product. Lets continue with the iphone example above, does that illogical stuff work for it? NO! No one buys a phone if it doesn’t have the required features and functionalities. Of course, brand value factor is very high of these kinds of products too . But no one can survive in type 3 products without its features(New and different).
Here are some of the products which fall into this category.
1. Phones and Gadgets
2. Automobiles
3. Television, Fridge etc

Type 4 (Visually Stunning).

The Levis ad , man who walks across America is the best example of visually stunning ads. Apart from the other types which focus on content, this type will be stressing on visual beauty. This Levis ad was one of the most viral video ads becuase of its visual creativity. A man walks all over America and all the whole video was limited to 1.5 minutes (which was a great achievement). No one can bounce out from the ad that quickly, once started viewing

Two ways to sort an array keeping its key in php

The sort function in array sorts the array very well, but it doesnt maintain the keys so that it becomes really painful sometimes. There will be several scenarios were we need to keep the keys of the associative arrays.

Luckily there are two functions in php which will help us to achieve this

1. uasort

uasort sort the array in the desired order (ascending or descending and will maintain the keys). It accepts two arguments,
1. The array to be sorted
2. The compare function

  $b) ? -1 : 1; 
        }  // Array to be sorted echo" pre="">";
        	
        $array = array('a' => 3, 'b' => 1, 'c' => -1, 'd' => -2, 'e' => 2, 'f' => -3, );
        echo "
";
        echo "Array Before Sorting 
"; print_r($array); echo "
"; // Sort and print the resulting array uasort($array, 'compare'); echo "Array After Sorting
"; print_r($array); ?>

The compare function return 1 or -1 which comes as the outcome of the bigger or smaller values(in the array) which has been compared.
Output

Array Before Sorting 
Array
(
    [a] => 3
    [b] => 1
    [c] => -1
    [d] => -2
    [e] => 2
    [f] => -3
)

Array After Sorting 
Array
(
    [a] => 3
    [e] => 2
    [b] => 1
    [c] => -1
    [d] => -2
    [f] => -3
)

2. asort

asort sorts the array and maintains its key. The sorting will only be in ascending order (from smallest to largest). We may need to reverse the array in order to sort it in the descending order. For that we can use the array_reverse function in php