CodeIgniter + jQuery + Json how to

Leave a comment

Controller define method like

public function getjson(){
			$arr = array(
			echo json_encode($arr);

Define view




					url		: "ajax/getjson",
					data	: "name=myname",
					type	: "post",
					dataType: "json",
					success : function(res){
					error	: function(res){




How to remove index.php from Codeigniter URL

Leave a comment

To do this just follows the following steps:

  • Open config.php from system/application/config directory and replace

$config[‘index_page’] = “index.php” by $config[‘index_page’] = “”

  • Create a “.htaccess” file in the root of CodeIgniter directory (where the system directory resides), open the file using your favorite text editor, write down the following script and save it:

Windows change to

RewriteEngine on
RewriteBase /ci/
RewriteCond $1 !^(index\.php|<span style="color: #ff0000;">js</span>|css|images|javascript)
RewriteRule ^(.*)$ index.php/$1 [L]

Mac change to

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
  • In some case the default setting for uri_protocol does not work properly. To solve this problem just replace

$config[‘uri_protocol’] = “AUTO” by $config[‘uri_protocol’] = “REQUEST_URI” fromsystem/application/config/config.php

Notepad++ and Zen Coding tips (Windows)

Leave a comment

Setup Zen Coding 

  • Plugins -> Plugin Manager -> Show Plugin Manager
  • Select Zen Coding – Python
  • Click Install
  • Done

Expand Abbreviation -> control + alt + enter

Example. type


press control alt enter

result is

<html lang="en-US">
	<meta charset="UTF-8">

Wrapping With Abbreviation -> shift + ctrl + alt + enter

Example. type

About Us
Contact Up

press shift + ctrl + alt + enter

popup appear type


click ok result is

<div id="header">
<ul id="navigation">
	<li class="item1"><a>
 About Us
	<li class="item2"><a>
	<li class="item3"><a>
	<li class="item4"><a>
	<li class="item5"><a>
 Contact Up

How to Indent html code(re-format) in notepad++?
– try use plugin XML Tools (Plugins -> XML Tools -> Pretty print .. )

How to do folding in notepad++?
– View -> Fold All, Unfold All, Collapse Current Level, ….