Pass Data with Ajax to PHP

Using the method below you can retrieve data from a database and run PHP scripts using the values of the forms and fields to pass the data from Ajax to PHP code. We will be using Ajax to collect and send the data from the forms to an PHP file, where we process it, and then return the results with Ajax again.

CREATING HTML PAGE

[html]
<input id="text1" type="text" /> +
<input id="text2" type="text" />
<button id="button"> = </button>
<div id="result"></div>
[/html]

PASSING DATA WITH AJAX

[html]
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
[/html]

Once we have the form and jQuery included in our document we need to store there values in 2 different variables that would be ( val1 and val2 ) so we can pass them to the PHP file to process further.

[php]
$(‘#button’).click(function() {
var val1 = $(‘#text1’).val();
var val2 = $(‘#text2’).val();
$.ajax({
type: ‘POST’,
url: ‘process.php’,
data: { text1: val1, text2: val2 },
success: function(response) {
$(‘#result’).html(response);
}
});
});
[/php]

We have created a “.click event” when the button with ID of #button is clicked, the it will call out function. after that we will get the value of each text field and assign it in val1 and val2.
Once we have the values we can now create an “$.ajax method”.

This method has 4 parameters.

  • type
  • url
  • data
  • success

If we use POST then in the PHP file, we use $_POST[”] to get the value. If we use GET then we use $_GET[]

PHP FILE

[php]
$text1 = $_POST[‘text1’];
$text2 = $_POST[‘text2’];
echo $text1 + $text2;
[/php]

Fast Tips CSS coding

lot of people struggling with CSS, from beginners to seasoned developers always have issues with selectors and advance control on there or pre defined CSS.
We can use some tips mentioned below to write and code for a better and easy to maintain CSS code for your global and private style sheets.

Viable selector

CSS is a declarative language, which means you have to assign some rules and elements in the DOM, this language works on rule precedence over the other in the order they are applied, example Inline styles overriding internal CSS.

For instance

<button class=“button-warning”>

.button-warning {
  background: red;
}

button, input[type=submit] {
  background: gray;
}

Despite .button-warning being defined before the button, input[type=submit] rule, it will override the latter background property.

Now the question arise Why? and how can we decide the criteria which rule will override the styles of another one?

Now first we have to understand that some selectors are considered to be more specific than others, for example an #id selector will override a .class selector.

What happens if we use a selector that is more specific than it really needs to be, example If we later want to override those styles, we need to define even more specific selector.
So, whenever you are writing your selectors, if is this the least specific selector that can do the job here.

For more specificity rules you can follow the “W3C CSS Selectors specification”

Dreamweaver’s Firebug is Code Navigator

Firebug in Dreamweaver’s Code Navigator

Taking a next step is all about the Code Navigator in Dreamweaver. When in the Live View window you just need to perform “ALT + clicking” for windows and “Command-Option + clicking” for Mac users anywhere in the window will instantly presents the code that rendered that item. Similar to what you might currently see in Firefox/Firebug.

Firebug

Adobe Photoshop CC Tips, Tricks

Merge All Layers to New Layer

IF you have Photoshop document with lots of layers or multiple layers, you may come to the stage where you need to merge all of these layers into one layer, while you still want to retaining your original layer structure. Well since there is no menu feature to do this in Photoshop, however there is a hidden hotkey. Cmd/Ctrl + Shift + Alt/Opt + E.

step1

This will combine everything and pop it onto a new layer in one fell swoop.

Step2

and you are done.

Grow Your Business with better Web Design

Building a great user friendly site can be a very difficult thing to do, and all new competition every second make it more difficult to stand in web market. The very vital and much important key here is to accept that you site is your Face on Web world and your action on your site are 100% responsible for all stages of your business. From Marketing to revenue generation all now depend upon how you treat your site and how active You are.

There are Some Key factor you must consider While launching your site.

Good Portfolio Responsive design

You need a very powerful and promising portfolio about your work or your business products and structure. Some good and live example will create a positive impact on visitors and attract new clients. Testimonials from past work and clients will create a deep impact on visitors.

Marketing Informative newsletters

Without spreading the word you cannot expect any to your shop, same implies for you web shop, you need follow deferent marketing standards and system to spread the word about your business to let users know your existence. Create content and blogs more often and post them regularly. Better the news letter better the response.