Javascript for Web Application Development - Object Developer
JavaScript Best Way for Web application development
Step1 : You need to include jquery library in you web application, remember this file put above to your script Step2 : You can download this library from this this website link or direclty you put this below file
firstly you create a script for alert any message, so you can check javascript is working or not in your application
<script>
$(document).ready(function(){
alert("Hello! its working");
});
</script>
Thats good, its working fine, if you have problem for set up you can comment below
For More Practice we implement some more script
Lets, we create a button, click event on button. When we click on button we want to trigger our action
Lets try...
Create a Button in your html body
we create a button, where we write a function onclick - checkMe, it means we click on this button, this checkme function call
<script>
function checkMe(){
alert("Yeah!! its working");
}
</script>
If you want to call your javascript by id (Click Event by ID)
Many times we need to call our javscript function by any ID / Classs
Lets, we create a button, give a ID name. When we click on button we want to trigger our action
Lets try...
Create a Button in your html body
we create a button, where we give a ID name - MyButtonID, it means we click on this button, this MyButtonID call
<script>
$("#MyButtonID").on('click', function(){
alert("On click function by ID");
});
</script>
you use on click function of javascript by id, for id you need # with id name just like ("#myID")
If you want to call by class then just replcae # with . like - (".myClassName")
How do pass variables from JavaScript to PHP and redirect to a PHP page after passing variables
Use Ajax Method for pass value and return get any result, so i create a function, i call a function and pass a value to ajax page, create a ajax.php page
<script>
function passdata(){
var passvalue="123";
$.ajax({
url:'ajax.php',
type:'GET',
data:{passval:passvalue}, //Pass your varibale in data
success:function(getreturn){
alert(getreturn); //you get return value in this varibale, us it anywhere
}
});
</script>
in ajax.php page you pass value by javacript get
$_GET['passval'];
echo "MyRetrunresult"; // pass your return result to ajax
I Write more javascript as soon, this is very important for your Software Development or Web Application Development