Problems with AJAX
Posted: Thu Mar 27, 2008 5:47 am
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hello,
I am trying to create a simple form where the user writes something in an input box, clicks on a button and the input box becomes what the user have inserted. I am pretty sure I am not doing something right with my ajax and js code so I am pasting it here. I will be happy to hear where am I wrong:
JS
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hello,
I am trying to create a simple form where the user writes something in an input box, clicks on a button and the input box becomes what the user have inserted. I am pretty sure I am not doing something right with my ajax and js code so I am pasting it here. I will be happy to hear where am I wrong:
JS
Code: Select all
<!--
//Browser Support Code
function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.myForm.value = ajaxRequest.responseText;
}
}
ajaxRequest.open("GET", "insert.php", true);
ajaxRequest.send(null);
function changeText2(){
var userInput = document.getElementById('userInput').value;
document.getElementById('title').innerHTML = userInput;
}
//-->~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: