Jump to content

ticklejuggle

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ticklejuggle's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for your reply. I did think the script was old, but they all seem to follow that same pattern, so I thought I'd try it... I am fairly new to programming, and I don't really expect to write all my own scripts, but I would like to understand them...So I will definately check those links out! I am finding that there are certain warning signs indicating you should run, when looking at other people's codes, I try to avoid 1. Incomplete codes, or codes missing necessary quotation or punctuation marks, obviously untested. 2. When the author says "I didn't try this but it should work." 3. Any sample codes that use tables to display non-tabular data, yikes!
  2. Hello all, thanks up front for reading this. I have found many seemingly simple scripts for making ajax calls, but can't seem to make any of them work. I am pulling out my hair, please tell me what is wrong with this. It is supposed to pass the entered text into an alert box, but when I click submit, I get nothing here is the html file: <html> <head> <script type="text/JavaScript"> <!-- function ajaxFunction() { "use strict"; 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; } } } } function ajaxGet() { var mygetrequest = new ajaxFunction(); var namevalue = encodeURIComponent(document.getElementById("name").value); var agevalue = encodeURIComponent(document.getElementById("age").value); mygetrequest.onreadystatechange = function () { if (mygetrequest.readyState == 4) { if (mygetrequest.status == 200 || window.location.href.indexOf("http") == -1) { document.getElementById("result").innerHTML = mygetrequest.responseText; } else { alert("An error has occured making the request"); } } } mygetrequest.open("GET", "basicform.php?name="+namevalue+"&age="+agevalue, true); mygetrequest.send(null); } //--> </script> </head> <body> <form method="get" action=""> Your name: <input type="text" id="name" name="name" /> <br /> Your age: <input type="text" id="age" name="age" /> <br /> <input type="button" value="submit" onsubmit="ajaxGet(); return false;" /> </form> <div id="result"> </div> </body> </html> and the php file <?php $name=htmlspecialchars($_GET['name']); $name=stripslashes($name); $age=(int)$_GET['age']; echo "Welcome <b>$name</b> to TickleJuggle.netne.net! So you're <b>$age</b> years old eh?"; ?> test link: ticklejuggle.netne.net *Hosted free at 000webhost.com, I love them * the php file loads see: ticklejuggle.netne.net/basicform.php?name=joe&age=25 Before you ask why I am not using a framework or library here are the reasons: 1. I want to learn this, the old way, for the purpose of learning and my own personal understanding, not to build web pages 2. When I choose a library or framework to use, to build actual web pages, I want to understand how ajax works and what I can reasonably expect it to do, to make an informed decision 3. When building actual applications, debugging will *hopefully* be easier if I understand this, even when using a framework or library
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.