Submitting a form via AJAX

Ok so here is a very simple yet descriptive example how web-forms can be submitted using AJAX. This is an advanced tutorial, so although I’ll try to explain everything,¬†I am assuming that the reader has a basic understanding of php and javascript.

AJAX is Asynchronous JavaScript And XML. Its a client side method to communicate data with a server. Asynchronous means that this communication can take place without interfering with other client side processes. (As we’ll see later, the asynchronous part is optional). Javascript is the main framework where AJAX works and XML is a format in which data might be communicated. Although this is not necessary. Data might be communicated in text, JSON, etc formats also.

Lets jump right in and look at this live demo.

Ok, lets look at the code now. The HTML structure is something like this:
http://pastebin.com/embed_iframe.php?i=tQEjujan

Continue reading

Advertisements

Socket Programming

Anyone who has done some kind of network programming will be aware of the concept of sockets.
For those,who haven’t ever done it,this may be a very good place to start.

Me and 2 of my friends recently created a chat-server application using sockets in C in linux environment.What happened was,that once server-client connection was established,when a client would send some data to the server,the server would send the data to all the other clients.It was a localhost appplication however,and the primary purpose was interprocess communication implemented as a chat application. Continue reading

Changing Body Background Image Using Javascript

Things are getting weirder.
So I was trying to set the background image of a website using javascript. The requirement was to set an image as a background and then setting the parameters background-position as center and background-repeat as no-repeat. So here was my initial code:

document.body.style.background = “url(images/middle-bg.jpg)”;
document.body.style.background-position = “center”;
document.body.style.background-repeat = “no-repeat”;

AND IT WAS NOT WORKING!!

I tried variations, searched the forums. There were variations like
Continue reading

C / C++ Programming in Linux – For starters

I have had a lot of requests on snippets of how to do C/C++ programming in Linux.
Thanks to KS sir ( yeah Khushil Saini sir) for giving us intro a proper way. Without him, I would have probably used DevCpp and lived on Windows. I will try to keep it short and simple unlike his notes ūüôā

Linux used is Ubuntu (any version will do). Language considered: C/C++ Continue reading

Why people dont get along with Programming

Many people who come to a tech college like NSIT want to start something new with no idea where to begin with. And just at the right moment they see some workshop about someone hacking into something and voila ,  the dude just hacked into the facebook account!

Thats¬†when it strikes your mind , “Wow thats so cool and also earns me money! Why not learn that!?

And then you start your journey only to realize a few days later, “I cant do this! Its a¬†headache! and¬†way out of my league. I can never be as good as that hacker if I go on like this.” without¬†realizing the fact that its not an overnight magic trick or a 1 week magic crash course that is going to give you super coding skills.

Initially everyone sucks at programming. So I decided to compile a list that identifies reasons and advice to improve your programming skills.

And you just might save yourself from doing This


Continue reading

Image capturing in matlab

If you are using a laptop with a camera. Then this is how one can open the camera in MATLAB.

Web cameras are viewed by Matlab as adapters. So to use the webcam we need to know the adapter name of our webcam. In most cases it’s “winvideo”
So to know that: we type the following command.
>>imaqhwinfo

So easily one can see that the installed adapters in my system are ‘coreco’ and ‘winvideo’
Now to use that adapter we need to make an object for it. This is how it’s done:


>>obj1

=

videoinput(‘winvideo’);

This creates an object to handle the web cam and can be henceforth used to operate the webcam.
The following simple command lets you preview the camera output.
>>preview(obj1);
voila, Now don’t blush. ūüôā

Line space in HTML

Cool, so after some frustrated googling, I found out a way to give spaces in html. Usually if you give lots of space between text in html it shows up as only one space.
To give more than one space, one can use this character:  

So if in HTML editor, I write something like:
Hi            there

then in the html page it will show up as:
Hi there

That’s where   comes in handy. So instead of space you’ll have to write something like:

Hi       there

to produce the desired effect.