Search the Community

Showing results for tags 'xmlhttprequest'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 5 results

  1. Hello, I have a question about how to send form data to the database, without reloading the entire page. I discovered working with xmlhttprequest. I managed to show text from another file by implementing a javascript function with xhr into my script. I don’t know much about javascript and don’t understand how a javascript form should be added to an existing function. Finally this should run a php script executing the code to add the form data to the database. <!DOCTYPE html> <html> <body bgcolor="grey"> <center> <br><br><br> <div style="height: 200px; width: 600px; border: solid 2px blue;"> <div id="kn_ze"> <form id="my_form" action=""> Give your name: <input type="text" name="fname"> <br> <input type="submit" value="Send" onclick="loadXMLDoc();"> <!-- <button type="button" onclick="loadXMLDoc()">send it</button> --> </form> </div> </div> <script> function loadXMLDoc() { /* document.getElementById("my_form").submit();*/ var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("kn_ze").innerHTML = this.responseText; } }; xhttp.open("GET", "prophp.php", true); xhttp.send(); } </script> </body> </html> test script to process the form data prophp.php : <?php echo '<br>test code here : '; if (isset($_POST['fname'])) { var_dump($_POST['fname']); // execute mysql queries } ?> 11) How are the form data placed in the existing function? (or should I create a second one? ) Maybe someone can help me out solving it.
  2. This is my Javascript code: var Data_Display var My_Data function Setup() { My_Data = new XMLHttpRequest(); My_Data.open("GET","http://localhost:8080/exist/rest/db/apps/HTML_Student/Database_Example.xq"); My_Data.send(); document.getElementById("Information").value = My_Data.responseXML; } This is my XML code: <xml> <svg> <svg_data>100</svg_data> </svg> </xml> This is my XQuery: xquery version "3.0"; for $Data in doc("Database_Example.xml")/xml/svg/svg_data where $Data = 100 return $Data When I ran the Javascript code, the computer gave me an Access Control Allow Origin error. It told me that I needed a CORS request. Since I have no idea what a CORS request is or how to insert it into my code, I'm stuck. Can anyone assist me?
  3. I am trying to fetch some images from a server, however I need them to come back in the order requested. Currently, the below returns the images back in a seemingly random order, I guess which ever are finished first. How can I ensure I get the images back in the order they were requested? var xhr = [];for (i = 0; i < count; i++){ (function (i){ xhr[i] = new XMLHttpRequest(); xhr[i].open( "GET", url + dir + "/" + i.toString() + ".png", true ); xhr[i].responseType = "arraybuffer"; xhr[i].onreadystatechange = function () { if (xhr[i].readyState == 4 && xhr[i].status == 200) { var arrayBufferView = new Uint8Array( xhr[i].response ); var blob = new Blob( [ arrayBufferView ], { type: "image/png" } ); console.log("xhr: " + i + ".png"); } }; xhr[i].send(); })(i); } I want it to always output: xhr: 0.png xhr: 1.png xhr: 2.png I currently get a mixture of, and including the above: xhr: 0.png xhr: 2.png xhr: 1.png Or: xhr: 1.png xhr: 2.png xhr: 0.png
  4. I'm trying to convert: http://techslides.com/demos/image-video/create.html to work with images on a server. Currently the demo above uses local files: if(filesarr.length>0){ //loop through them and process for(i=0; i<filesarr.length; i++) { var file = filesarr[i]; if(file.type.match(/image.*/)){ process(file); } else { document.getElementById('status').innerHTML = "This file does not seem to be a image."; } } } else { document.getElementById('status').innerHTML = "Please select some images."; } I'm trying to fetch them from a server, so I have replaced the above with: for(i=0; i < 2; i++) { var url = "http://localhost/uploads/" + i.toString() + ".png"; var file = new Blob(); var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'blob'; xhr.onload = function(e) { if (this.status == 200) { file = new Blob([this.response], {type: 'image/png'}); process(file); } }; xhr.send(); } Could someone tell me what I am doing wrong? I am not getting any errors so I have no idea. EDIT: I feel very silly, there is nothing wrong with the above. I was still checking against the size of filesarr further down the script.
  5. Hello, im trying to create a nice file uploader using XmlHttpRequest so that we can get a nice progress bar and stuff without reloading the page. When I try to upload using my code the progress bar does show and count % up untill completed but no file is being uploded. I will show you my code and tell you what I think is wrong, but I will strip it down a bit. This is my js part: function uploadFile() { var xhrObj = new XMLHttpRequest(); var filesToBeUploaded = document.getElementById("fileControl"); var file = "filename="+filesToBeUploaded.files[0]; xhrObj.upload.addEventListener("progress", progressFunction, false); xhrObj.upload.addEventListener("load", transferCompleteFunction, false); xhrObj.open("POST", "upload.php", true); xhrObj.setRequestHeader("Content-type", file.type); xhrObj.send(file); } My form is not important, its a button with onclick="uploadFile()". But my upload.php might not be correct. This is where I wonder if I can use this:move_uploaded_file($_FILES['Filedata']['tmp_name'], "files/".$name."/".$filename) my upload.php: <?phpsession_start(); //Set some variables$name = $_SESSION['name'];$filename = $_POST['filename'];$key = uniqid(); // Move uploaded fileset_time_limit(0); if(move_uploaded_file($_FILES['Filedata']['tmp_name'], "files/".$name."/".$filename)){ // Update database}?>