Follow Me:

Saturday 10 January 2015

mysql> desc codingslover;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| ProjId   | varchar(20) | NO   | PRI | NULL    |       |
| BranchId | int(11)     | YES  |     | NULL    |       |
| AddedOn  | datetime    | YES  |     | NULL    |       |
| Status   | int(11)     | YES  |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> desc codingslover ProjId;
+---------+-------------+------+-----+---------+-------+
| Field   | Type        | Null | Key | Default | Extra |
+---------+-------------+------+-----+---------+-------+
| ProjId  | varchar(20) | NO   | PRI | NULL    |       |
+---------+-------------+------+-----+---------+-------+
1 row in set (0.00 sec)


How to resolved when Logged out sessions get restored by back button?

When we log out the sessions , We clear the cookies in browser. But when we press the back button after logging out the session gets restored. 
Solution:

 header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

Sunday 30 November 2014

Contains() Property in javascript.,it is working fine in Mozila Firebox only.It will not support Chrome Browser,Internet Browser,Safari,Opera browser.


Mozila Browser :


  var ClearFilterValue  = 'family Schools';
    if(ClearFilterValue.contains("family")== true) {
   alert('Success');
    } 
  

Chorme & Mozila Firebox Browser :

    The below javascript index() properity will working for both chrome and mozile firbox.It is functionality similar to contains property.

var ClearFilterValue  = 'family Schools';
alert(ClearFilterValue.indexOf("family") != -1);

var n  =   str.indexOf("family"); 
if(n >= 0) { 
    alert(success); 
}


Monday 3 November 2014

JSON (Javascript Object Notation) is a convenient way to transport data between applications, especially when the destination is a Javascript application.

Example :
Here is a minimal example that uses JSON as the transport for the server response. The client makes an ajax request with the JQuery shorthand function $.getJSON. The server generates a hash, formats it as JSON and returns this to the client. The client formats this and puts it in a page element.

Server:
get '/json' do
 content_type :json
 content = { :response  => 'Sent via JSON',
            :timestamp => Time.now,
            :random    => rand(10000) }
 content.to_json
end

Client:
var url = host_prefix + '/json';
$.getJSON(url, function(json){
  $("#json-response").html(JSON.stringify(json, null, 2));
});
 
Output:
  {
   "response": "Sent via JSON",
   "timestamp": "2014-06-18 09:49:01 +0000",
   "random": 6074
  }

JSONP (JSON with Padding)

JSONP is a simple way to overcome browser restrictions when sending JSON responses from different domains from the client. The only change on the Client side with JSONP is to add a callback parameter to the URL.

Server:
get '/jsonp' do
 callback = params['callback']
 content_type :js
 content = { :response  => 'Sent via JSONP',
            :timestamp => Time.now,
            :random    => rand(10000) }
 "#{callback}(#{content.to_json})"
end

Client:
var url = host_prefix + '/jsonp?callback=?';
$.getJSON(url, function(jsonp){
  $("#jsonp-response").html(JSON.stringify(jsonp, null, 2));
});

Output:
 {
  "response": "Sent via JSONP",
  "timestamp": "2014-06-18 09:50:15 +0000",
  "random": 364
}