In this post I want to explain loading javascript files with jquery. Here demo regional language textbox contains many javascript files, so just loading files with jquery when the file required. It's useful to faster your page loading time. Live Demo
Live Demo
Download India Regional Language Textbox Script Only for Email Subscribers.
Note: If you already email subscriber just mail to srinivas[at]inbox.com
Sample Script
<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function()
{
$(".language").change(function(){
var id = $(this).attr("value");
if(id == 'hindi')
{
$.ajax({
type: "GET",
url: "hindi.js",
dataType: "script"
});
}
else
{
$.ajax({
type: "GET",
url: "telugu.js",
dataType: "script"
});
}
return false;
});
});
</script>
<select class="language">
<option value="hindi" >Hindi</option>
<option value="telugu">Telugu</option>
</select>
ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function()
{
$(".language").change(function(){
var id = $(this).attr("value");
if(id == 'hindi')
{
$.ajax({
type: "GET",
url: "hindi.js",
dataType: "script"
});
}
else
{
$.ajax({
type: "GET",
url: "telugu.js",
dataType: "script"
});
}
return false;
});
});
</script>
<select class="language">
<option value="hindi" >Hindi</option>
<option value="telugu">Telugu</option>
</select>
The original unicode script developed by Gopi higopi.com. I had modified the script with jquery to control the language scripts.
well another nice idea here :)
ReplyDeletethanks for share
regards
nice script thanks for sharing.
ReplyDeletegood i like it
ReplyDeleteu think different....
ReplyDeletethanks srinivas
ReplyDeletethanks :D..
ReplyDeleteyou may save a couple of lines using jQuery.getScript
ReplyDeletecan you create a script that shows the "loading..." while the data is being retrieved from the database?
ReplyDeletecan u pls explain that,how do create javascript language files?
ReplyDeleteYou r great man!!!
ReplyDeleteowsome.......u r great dude..
ReplyDeletehow to get it for foreign languages [email protected]
ReplyDeletesuper to implement all languages.
ReplyDeletenice
ReplyDeleteVery Nice.. Great Coding Technique.. Awesome Thanks for sharing.
ReplyDeleteUseful Coding.. It is Working Good.. Awesome Thanks..
ReplyDeleteHow to use it for french language
ReplyDelete