0

Hi,

I have these two files...index.html and handle.php

Index.html has a form on it which is sent to handle.php. This file takes the data sent from index.html then processes it and returns some text.

What I want to do is 'Ajaxify' this whole process, so to speak.

How can I do this?

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Luckychap
0

On your form's onsubmit event call a js function which will initiate the ajax request.

.
.
.
<form onsubmit='sendAjaxRequest(this)'>
    <input type='text' name='textfield1'>
    .
    .
    .
</form>
.
.
.

And in js code initiate the ajax request

function sendAjaxRequest(form) {
    var param1 = form.textfield1.value;
    var param2 = .....;

    var url='path for handle.php?param1=' + param1 + '&param2=' +  param2 + '&'.....;
    // Send Ajax request
    
}

// Success Handler for the Ajax request
function successHandler() {
    // Code to update the page (index.html)
}

This is a brief road map to implement ajax.
For more details read more about how to implement ajax.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.