Connecting & Displaying message from ASP by AjaxHere we will use one simple form with one submit button. On clicking of the submit button we will trigger the ajaxFunction and submit data to our server side ASP script. There is nothing much in our ASP page, it will only return a message 'Hello World' which we will display in out html page. So let us start with the easy part the post.asp page.
The message "Hello World" will be displayed by the browser at our html page.
As we will be using XMLHttp Request object in all our scripts, you can read more on XMLHttp Request object here. The HTML page will have Ajax function inside the head tag and within the <script> tag. It will have our form inside its <body > tag. We will start with our Ajax function first. Here it is .
As you have seen in above code the first part is to establish the XMLHttp request object. Then we will use the function getFormData to collect the form inside values. Here we don't have any thing but we will be adding different components like textbox , checkbox etc in next tutorial.
Here is the code inside our <body> tag.
We have used POST method for our form submission and we have kept the form inside one Div layer so we can control its display property in future.
You can download the two files used post.htm & post.asp file here.
This article is written by plus2net.com team.
Number of User Comments : 2 | ||||||||||
| ||||||||||