Archive for month: March, 2012

jQuery Ajax Post

Categories: AJAX, javascript, jQuery

jQuery provides a quick, robust and easy way to request data from the server without a page reload through AJAX. In this short article we’ll look at loading data from the server using a HTTP Post Request.

jQuery $.post function

There is a shorthand AJAX post function with the following signature:

$.post({
  url: 'myTargetURL.php',
  data: data,
  success: success function(data, textStatus, jqXHR),
  dataType: dataType
});

jQuery $.ajax Post Function

I prefer to use the default .ajax function for ease of use and maintainability.

$.ajax({
type: 'POST',
url: 'myTargetURL.php',
data: data,
success: success function(data, textStatus, jqXHR),
complete: function(),
dataType: dataType
});
You’ll notice that they both accomplish the same thing, however, the $.ajax function has more flexibility. Just a personal preference.

jQuery AJAX Post Parameters

Here is the rundown on pass parameter:
type – HTTP Request Type. In this case ‘POST‘, but could be ‘GET‘ as well.
url – A string containing the URL to which the request is sent. Eg: HTTP://www.Yourdomain.com/YourAjaxScript.php

data – A map or string that is sent to the server with the request.

success(data, textStatus, jqXHR) – A callback function that is executed if the request succeeds.

complete() – A callback function that is executed when everything is complete.

dataType – The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).

jQuery Ajax Error Handling

The jQuery $.ajax function has a very robust error handling system. You can read more about it’s implementation in the jQuery Ajax Error Handling Function post.

jQuery Ajax Post Example

$.ajax({
        url: "/form.php",
        type: "post",
        data: serializedData,
        // callback handler that will be called on success
        success: function(response, textStatus, jqXHR){
            // log a message to the console
            console.log("It worked!");
        },
        // callback handler that will be called on completion
        // which means, either on success or error
        complete: function(){
            // enable the inputs
            $inputs.removeAttr("disabled");
        }
    });

Google Local SEO Lessons

Categories: Local, SEO

Getting Your Business on Google Maps

If you’re a local business and are looking to drive local customers to your business site, a great place to start is Google places and Google maps. According to a new study from Bizible there are a few easy things you can do to improve your SEO and move up in the Google local rankings.

Two Parts to a Local Search Query:

  • 1The search city – “Portland” when searching for “Portland pizza.”
  • 2The search category – “pizza” when searching for “Portland pizza.” We also generated a list of synonyms for the search category

Integrated Search Results Factors:

  • 1Having the primary category match a broader category of the search category was associated with a 1.42 improvement in rank. For example, primary category is set to “restaurant” and the search category was “pizza.”
  • 2Having the search category or a synonym in the business name was associated with a 0.64 improvement in rank.
  • 3Having the search category or a synonym in “at a glance” was associated with a 0.36 improvement in rank.
  • 4Having five or more Google reviews was associated with a 0.31 improvement in rank.(more than 5 does little to improve your rank)
  • 5Having photos (at least 1) was associated with a 0.25 improvement in rank.

The average ranking improvement for listing that implement these suggestions improved by about three positions. That is significant when you realize that on average there are only 5 integrated results listed for a search.

Pure Local Search Results Factors:

  • 1Having five or more Google reviews was associated with a 1.47 improvement in rank.
  • 2Having the search city in “at a glance” was associated with a 1.42 improvement in rank.
  • 3Having the search category or a synonym in in review content was associated with a 0.97 improvement in rank.
  • 4Having the search category or a synonym in the business description was associated with a 0.85 improvement in rank.
  • 5Having the search category or a synonym in “at a glance” was associated with a 0.85 improvement in rank.
  • 6Having the primary category match the search category was associated with a 0.79 improvement in rank.
  • 7Having the search category or a synonym in in the business name was associated with a 0.75 improvement in rank.
  • 8Having a secondary business category that was a broader category than the search category was associated with a 0.68 improvement in rank. i.e. secondary category is “restaurant” when searching for “Portland pizza.”
  • 9Having at least one photo was associated with a 0.66 improvement in rank.
  • 10Owner verified was associated with a 0.52 improvement in rank.

Listings using these factors on average saw a ranking improvement of 9 positions.

Search Engine Optimization Consulting

As you can see there are a few things to do to make a big difference in the SEO of your business listing. We at Unseen Revolution are search engine optimization specialists and can help you improve search engine ranking, list on Google Places for business, or list your business on Google maps.

The full report can be reviewed by visiting bizible.com

Solution: Firefox Font-Face Cross Domain Problem

Categories: Apache, CSS, Firefox, HTML

Firefox Font-Face Cross Domain Problem:

The other day I was working on a website that we were accelerating with a content deliver network (CDN). All the static content was to go through the cdn including the styles (css) file. We ran into a weird bug on Firefox. Font-face styles were not showing. The fonts were loading off the cdn.mysite.com sub domain while the rest of the site was running off mysite.com.

@font-face{
	font-family:'PreloSlab';
	src:url('../fonts/preloslab-medium-webfont.eot');
	src:url('../fonts/preloslab-medium-webfont.eot?#iefix') format('embedded-opentype'),
		url('../fonts/preloslab-medium-webfont.woff') format('woff'),
		url('../fonts/preloslab-medium-webfont.ttf') format('truetype'),
		url('../fonts/preloslab-medium-webfont.svg#PreloSlabMedium') format('svg');
	font-weight:normal;font-style:normal
	}

Reason:

Seems that Firefox supports the Cross-Origin Resource Sharing standard (CORS) for HTTP requests of some types of resource. This is a way for a remote host to control access to some types of resource. As it turns out, web fonts are subject to CORS. So, the appropriate Access Control headers need to be sent to the browser to allow the domain originating the request (the Origin) access to the resource.

Firefox Font-Face Cross Domain Solution:

Seems messy but it really isn’t. The correct header is:

Access-Control-Allow-Origin: http://mysite.com

On an Apache server you can accomplish this with a little edit to the .htaccess file.

<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
  <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "http://mysite.com"
  </IfModule>
</FilesMatch>
Note: while you should be able to list several domains separated by a comma. This did not work. I had to use Header set Access-Control-Allow-Origin “*” for multiple domains.

Font-Face Mime Types

While you are at it, you can also add the correct mime types to the files.

AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType application/x-font-woff woff
© 2018 - www.UnseenRevolution.com - Unseen Revolution LLC. 333 NW 4th Ave. Portland, OR 97209
5bc41aa6093b3
By
UnseenRevolution.com Portland, OR Category: Webinar
UnseenRevolution.com Portland, OR Category: Webinar
UnseenRevolution.com Portland, OR Category: Webinar