haha. I add jquery for default. Here, I use in my view like this
<html>
<head>
<?php
/* add script from code.jquery.com $this->jq->get_latest(); */
//you can also load like this $this->load->js('jquery');
$this->jq->noconfilt=true //for jquery no conflit
$this->jq->get_script();
?>
<script>
<?php $this->jq->start_jq(); ?>
alert("I'm jquery");
<?php $this->jq->end_jq(); ?>
</script>
</head>
<body> </body>
</html>
Today, I am making ornagai dictionary with jquery. I was thinking about at 7:00 at English Tuition. At 12:00 pm, I was staring the code for that. It was complete in a half hour. However, it's using 20 KB JSON file. So, I thought it, "Can I do complete dictionary in one JSON file ? " I export the JSON from mysql database. It had 4 MB. And then run in my code. Oop!!! My firefox had been hung. I restart my firefox and changing my code. I will show just 9 results and try again it. It was ok but too long to wait. So, I decided to make index the JSON. I made a.json to z.json and then search again. Amazing... I said "Awesome!!!" It's so fast and unbelievable searching. I love jquery and JSON. I finished that project just in 2 hours. You can download JqueryDict in there. I am thinking about Myanmar to the English dictionary with JqueryDict but it should make many indexs for ka to arh. So, I will do when I have a free time.
Cheer!!!
It can make easy with jquery and php. Jqueyr also include ajax function and we can make easily that. First download jquery file from www.jquery.com. I made search.html and code is follwoing.
searching.html
[sourcecode lang="xhtml"]<html>
<head>
<title>AJAX Search Simple</title>
<script src="jquery.js"></script>
<script>
$(document).ready(function() {
</html>[/sourcecode]
I am using keyup function for id q. ( #q mean id q that is textbox ) After keyup get value from text box and write text searching in result (div). I send query string to result.php. You will see result.php is following
result.php
[sourcecode lang="php"]
<?php
//You can write some code in there.
//Connect Database and make sql query in here
echo "Search For ".$_GET['data'];
?>[/sourcecode]
You should add some code in PHP for search in database. It's a simple. You can download complete code in here.
Today, I am think about ornagai api. I should export with JSON because json is easy to read data with javascript library (mootools,jquery,etc..) and also with PHP. So, I tring with Jquery to read json. Oh! it's so easy and so nice for me.
This is a data.json
{
"data":
[{
"word":"A",
"state":"art",
"def":" the first letter of the English alphabet"
},
{
"word":"Art",
"state":"n",
"def":"the quality, production, expression, or realm, according to aesthetic principles, of what is beautiful, appealing, or of more than ordinary significance"
}
,
{
"word":"Saturn",
"state":"n",
"def":"an ancient Roman god of agriculture, the consort of Ops, believed to have ruled the earth during an age of happiness and virtue, identified with the Greek god Cronus."
}] }
This is my jquery code
[sourcecode lang='js'] $(function() { $.getJSON("data.json", function(json) { alert(json.data[1].def); $.each(json.data,function(i,mydata){ $("#result").append(mydata.word+"<br>"); }); }); }); [/sourcecode]Complete HTML code is
[sourcecode lang='xhtml'] <html>Today, I wrote PHP,Jquery code for shortest URL that are bit.ly and tinyurl. I get PHP code from http://davidwalsh.name/ and then I combine with Jquery. Bravo! It's so useful for me. Light weight and faster than their home site becuase of graphic ;). By the way, I am written this site with HTML 5 and you need to firefox 3.5 or Chrome 2