Rss Feed
  1. Ajax loading

    Monday 7 July 2014

    Link: 

    http://jquery.malsup.com/block/#page

  2. To make the browser use the correct encoding, add an HTTP header like this:

    header("Content-Type: text/plain; charset=ISO-8859-1");

    or put the encoding in a meta tag:

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

  3. Alphanumeric, dash and underscore but no spaces regular expression check Javascript


    var regexp = /^[a-zA-Z0-9-_]+$/;
    var check = "checkme";
    if (check.search(regexp) == -1)
        { alert('invalid'); }
    else
        { alert('valid'); }


    Only Alphanumeric  regular expression check Javascript


    var regexp = /^[a-zA-Z0-9]+$/;
    var check = "checkme";
    if (check.search(regexp) == -1)
        { alert('invalid'); }
    else
        { alert('valid'); }

  4. Friendly url

    http://pt.com/sicsdev/ln10/qttracksubcampaign

    Original URL.
    http://pt.com/sicsdev/trakk/lnk/index.php?ctype=1&cparm=0&cname=qttracksubcampaign

    This URL rewrite is done in .htaccess file. Code that helped to do this is
    RewriteRule 
    -----------------------------------------------------------------------------------------------------------
    RewriteEngine On

    RewriteRule ^ln([0-6])([0-2])/([a-zA-Z0-9-\_]+)$ ./trakk/lnk/index.php?ctype=$1&cparm=$2&cname=$3

    RewriteRule ^ln([0-6])([0-2])/([a-zA-Z0-9-\_]+)/$ ./trakk/lnk/index.php?ctype=$1&cparm=$2&cname=$3

    ------------------------------------------------------------------------------------------------------------

    In this many things I had learned

    1.In the friendly url there is a parameter In10. From this parameter ctype and cparm value is obtained.

        How its possible?
         In this parameter In10, prefix part In will be static. So with the help of static value its possible to get succeeding values using regular expression. Check RewriteRule to find it out

    RewriteRule ^ln([0-6])([0-2])/([a-zA-Z0-9-\_]+)$ ./trakk/lnk/index.php?ctype=$1&cparm=$2&cname=$3

           In the above rule following the static parameter value(In),([0-6]) will give first dynamic parameter value $1 also it limits value of parameter from 0 to 6.([0-2]) will give second dynamic parameter value $2 also it limits value of parameter from 0 to 2.Succeeding slash(/) is mentioned for adding third parameter.
    ([a-zA-Z0-9-\_]+) will give third parameter value $3.
    We can pass the obtained parameter value to the original URL like ?ctype=$1&cparm=$2&cname=$3

    2. ([0-6]) using this regular expression will limit parameter value.

    3. If we use all the regular expression to receive parameter value  in the RewriteRule at once as above then its mandatory to supply all the parameter through URL.

    Eg: Lets consider two url to understand

    URL 1: Need to pass two parameter at once

    Friendly Url -> www.eg.com/type/id

    Orginal Url -> www.eg.com/edit.php?t=type&id=id

    RewriteRule

    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ edit.php?t=$1&id=$2
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ edit.php?t=$1&id=$2

    In the above the case two parameter is mandatory at once. So can use above code at once for both parameter value.


    URL 2: Need to pass two parameter. But both the parameters are not mandatory.

    Friendly Url -> www.eg.com/type/id

    Orginal Url -> www.eg.com/edit.php?t=type&id=id

    RewriteRule

    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)$ edit.php?t=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ edit.php?t=$1

    //Second Parameter 
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ edit.php?t=$1&id=$2
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ edit.php?t=$1&id=$2

    In the above the case two parameter is  not mandatory at once. So need to use rewrite Url for both the parameters.

  5. Pretty URLs always helps you to boost up search engine page ranking. In this post I want to explain about URLs rewriting techniques using .htaccess file. Friendly URLs looks neat on the browser address bar. 

    Original URL.
    Eg. http://flickr.com/users.php?id=username&page=2 

    Rewriting Friendly URL.
    Eg. http://flickr.com/username/2

    .htaccess Code
    //First Parameer
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)$ users.php?user=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ users.php?user=$1

    //Second Parameter 
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ users.php?user=$1&page=$2
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ users.php?user=$1&page=$2

    Demo: http://www.9lessons.info/2009/11/pretty-urls-with-htaccess-file.html


  6. Jquery get key press button event

    Friday 25 April 2014

    <input type="text" name="txt1" onKeyPress="SearchName(event)" value="<Type To Search>" >

    function SearchName(e, txtObj, selObj) {
      evt = e || window.event;
      var keyPressed = evt.which || evt.keyCode;
    }

  7. Upload file via ajax jquery php

    Monday 14 April 2014

     $.ajax({
              type : "POST",
             /* data : $('#reg-restaurant-form').serialize(),*/        
                    contentType: false,
                    processData: false,
             data :new FormData($('#reg-restaurant-form')[0]),
              url  : myBaseUrl+('/UsersActions/restaurantUserAdd'),
                    success : function(opt){
    }
    });