Jump to content

Search the Community

Showing results for tags 'ajax'.

  • 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

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

  1. I'm trying to select data from a MySQL database that is hosted on a webserver. I want to be able to retrieve the data from a table within the database and then illustrate it within a HTML table. There's an example on W3Schools that I've been following, but I'm unable to retrieve the data successfully. http://www.w3schools.com/php/php_ajax_database.asp Below is the source code: (HTML) <html> <head> //Javascript code <script> function showUser(str) { if (str == "") { document.getElementById("txtHint").innerHTML = ""; return; } else { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("txtHint").innerHTML = this.responseText; } }; xmlhttp.open("GET","getuser.php?q="+str,true); xmlhttp.send(); } } </script> </head> <body> <form> <select name="users" onchange="showUser(this.value)"> <option value="">Select a person:</option> <option value="1">Peter Griffin</option> <option value="2">Lois Griffin</option> <option value="3">Joseph Swanson</option> <option value="4">Glenn Quagmire</option> </select> PHP File: (getuser.phd) <!DOCTYPE html> <html> <head> <style> table { width: 100%; border-collapse: collapse; } table, td, th { border: 1px solid black; padding: 5px; } th {text-align: left;} </style> </head> <body> <?php $q = intval($_GET['q']); $con = mysqli_connect('www.example.com','user_Admin','12345-678','my_DB'); if (!$con) { die('Could not connect: ' . mysqli_error($con)); } mysqli_select_db($con,"ajax_demo"); $sql="SELECT * FROM user WHERE id = '".$q."'"; $result = mysqli_query($con,$sql); echo "<table> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> <th>Hometown</th> <th>Job</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "<td>" . $row['Age'] . "</td>"; echo "<td>" . $row['Hometown'] . "</td>"; echo "<td>" . $row['Job'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> </body> </html> *MySQL table is attached I think the issue might exist from mysqli_select_db($con,"ajax_demo"); onwards inside the PHP file. Should I be referring to the table that contains the data inside the database? I have the PHP File hosted on my webserver, so I'm not sure why it won't retrieve that data when a person is selected from the list of options on the HTML page. Any help would be much appreciated.
  2. Is it possible to add a 1 vote per IP restriction for this poll without using php? If not with IP restriction, how could a repeated voting of the same person be avoided? How can a Results link be added? Where should it refer? Thank you!
  3. Hi, I'm trying to get a form where you submit information about a home to a database and below the form it displays the homes with the information and a photo. Below the home information and photo I have a button to DELETE RECORD and a button to upload a photo. All of the php and forms are in one file so submitting the home info and deleting record are just have action="samefile.php". This is so that it stays on the same page and doesn't have to jump to another page. I cannot get the upload photo to stay on the same page. The only way I can get the upload photo to work is to send it to another file. This of course takes me to another page which I don't want. I want everything to stay on the same page. The code I have (in a file called "PicTest03.php) is as follows: <!DOCTYPE html> <head> </head> <html> <body> <form action="PicTest03.php" method="POST"><pre> Name <input type="" name="name"> Bedrooms <input type="text" name="bedrooms"> Length <input type="text" name="length"> Width <input type="text" name="width"> Serial Number <input type="text" name="serialno"> <input type="submit" value="ADD RECORD"> </pre> </form> <br><br><br> <?php require_once 'login.php'; $conn = new mysqli($hn, $un, $pw, $db); if ($conn->connect_error) die($conn->connect_error); if (isset($_POST['delete'])&& isset($_POST['serialno'])) { $serialno = get_post($conn, 'serialno'); $query = "DELETE FROM holidayhomes WHERE serialno='$serialno'"; $result = $conn->query($query); if (!$result) echo "DELETE failed: $query<br>" . $conn->error . "<br><br>"; } if (isset ($_POST['name']) && isset ($_POST['bedrooms']) && isset ($_POST['length']) && isset ($_POST['width']) && isset ($_POST['serialno'])) { $name = get_post ($conn, 'name'); $bedrooms = get_post ($conn, 'bedrooms'); $length = get_post ($conn, 'length'); $width = get_post ($conn, 'width'); $serialno = get_post ($conn, 'serialno'); $query = "INSERT INTO holidayhomes (name, bedrooms, length, width, serialno) VALUES ('$name','$bedrooms', '$length', '$width', '$serialno')"; $result = $conn->query($query); if (!$result) echo "INSERT failed: $query<br>" . $conn->error . "<br><br>"; } $query = "SELECT * FROM holidayhomes"; $result = $conn->query($query); if (!$result) die ("Database access failed: " . $conn->error); $rows = $result->num_rows; for ($j = 0 ; $j < $rows ; ++$j) { $result->data_seek($j); $row = $result->fetch_array(MYSQLI_NUM); echo <<<_END <pre> name $row[0] Bedrooms $row[1] Length $row[2] Width $row[3] Serial No $row[10] MainPic $row[4] <img src="uploads/$row[4]" width=200 height=200> </pre> <pre> <form action="PicTest03.php" method="POST"> <input type="hidden" name="delete" value="yes"> <input type="hidden" name="serialno" value="$row[10]"> <input type="submit" value="DELETE RECORD"> </form> </pre> <pre> <form action="mainphoto01.php" method="post" enctype="multipart/form-data"> Select main photo: <input type="hidden" name="serialno" value="$row[10]"> <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload Image" name="submit"> </form> </pre> <br><br> _END; } $result->close(); $conn->close(); function get_post($conn, $var) { return $conn->real_escape_string($_POST[$var]); } ?> </body> </html> The code for "mainphoto01.php is: <?php require_once 'login.php'; $conn = new mysqli($hn, $un, $pw, $db); if ($conn->connect_error) die($conn->connect_error); $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file, PATHINFO_EXTENSION); if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false){ echo "FIle is an image - " . $check["mime"] . "." ; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } if ($uploadOk == 0){ echo "Sorry, your file was not uploaded."; } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)){ echo "The file " . basename( $_FILES["fileToUpload"]["name"]) . " has been uploaded."; } else { echo "Hello!"; } } $mainpic = basename( $_FILES["fileToUpload"]["name"]); if(isset($_POST["serialno"])) $serialno = $_POST['serialno']; $query = "UPDATE holidayhomes SET mainpic='$mainpic' WHERE serialno='$serialno'"; $result = $conn->query($query); if(!$result) echo "INSERT failed: $query<br>" . $conn->error . "<br><br>"; ?> No matter what I try I cannot get the above code to work if I keep it in the "PicTest03.php" file. Can someone please show what the code should look like so I can get everything to show on the same page? I have had a look as the PHP and AJAX and DATABASE http://www.w3schools.com/php/php_ajax_database.asp which I got the example working but it uses a drop down list. Is there a way to convert the code used for the example on http://www.w3schools.com/php/php_ajax_database.asp and instead of drop down list just have the information from the database shown under the form for submitting the home information?
  4. Hello, I am trying to create a proof of concept webpage that changes text in response to a button press using an MVC pattern (or at least as I understand it), and Ajax to avoid reloading the page. (I would like to implement Ajax in a larger MVC program I am working on but thought I would try to get it to work small-scale first). From playing around with examples here and here: https://www.sitepoint.com/the-mvc-pattern-and-php-1/ http://www.w3schools.com/php/php_ajax_php.asp I have the program working with each component individually (it works with the MVC pattern if I don't mind reloading the page to update the text, or it works without reloading the page if I don't mind essentially scrapping the MVC pattern). However, I'm trying to get both to work at once. I have combined the two examples so that the view uses Ajax to call the appropriate controller function, which successfully modifies the model (I'm sure this part works from debugging the program). However, when I try to refresh the content of the page using the output function of the view, nothing happens without reloading the page. Here is my code so far: <html> <head> <meta charset="UTF-8"> <!--ajax attempt--> <script> function callTextChange () { var xmlhttp = new XMLHttpRequest(); //if uncommented, this changes the text, but it doesn't fit with my MVC pattern /*xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("text").innerHTML = "changed with purely Ajax, without using MVC"; } };*/ xmlhttp.open("GET", "index.php?action=changeText", true); xmlhttp.send(); } </script> </head> <body> <?php class Model { public $text; public function __construct() { $this->text = 'default'; } function changeText () { $this->text = 'changed'; } } class View { private $model; public function __construct(Model $model) { $this->model = $model; } public function output() { //regular MVC method using button as a link //return $this->model->text.'<a href="?action=changeText"><button>change text</button></a>'; //attempted ajax method using button on click attribute to make an Ajax call return '<p id="text">'.$this->model->text.'</p>'.'<button onclick="callTextChange()">change text</button>'; } } class Controller { private $model; public function __construct(Model $model) { $this->model = $model; } function changeText() { $this->model->changeText(); } } $model = new Model(); $controller = new Controller($model); $view = new View($model); if (isset($_GET['action'])) { $controller->{$_GET['action']}(); } echo $view->output(); ?> </body> Any idea how to do what I'm trying to do? Is this even possible? Help would be much appreciated
  5. $( document ).ready( function(){ //this will fire once the page has been fully loaded $( '#comment-post-btn' ).click( function(){ comment_post_btn_click(); }); }); function comment_post_btn_click() { //Text within textarea which the person has entered var _comment = $( '#comment-post-text' ).val(); var _userId = $( '#userId' ).val(); var _userName = $('#userName').val(); if( _comment.length > 0 && _userId != null ) { //procced with ajax callback $('.comment-insert-container').css('border' , '1px solid #e1e1e1' ); $.ajax({ type: "POST", url: "/ajax/comment_insert.php", data: { task : "comment_insert", userId : _userId, comment : _comment }, error : function( ) { console.log("Error: " ); } , success : function(data) { comment_insert( jQuery.parseJSON(data)); console.log( "ResponseText: " + data); } }); console.log( _comment + " UserName: " + _userName + " User Id: " + _userId ); } else { //the textaarea is empty, lets put a border of red in italics //in a second $('.comment-insert-cotainer').css('border' , '1px solid #ff0000 '); console.log( "The text area was empty" ); } //remove the text from the text area, ready for another comment //possibly $( '#comment-post-text' ).val(""); }; function comment_insert( data ) { var t = ''; t += '<li class="comment-holder" id="_'+data.comment_id+'">'; t += '<div class="user-img">'; t += '<img src="'+data.profile_img+'" class="user-img-pic" />'; t += '</div>'; t += '<div class="comment-body">'; t += '<h3 class="username-field">'+data.userName+'</h3>'; t += '<div class="comment-text">'+data.comment+'</div>'; t += '</div>'; t += '<div class="comment-buttons-holder">'; t += '<ul>'; t += '<li class="delete-btn">X</li>'; t += '</ul>'; t += '</div>'; t += '</li>'; $( '.comments-holder-ul' ).prepend( t ); } Hi all, I was wondering if somoneone could help me out with my problem. I am a complete beginner, so you may have to dumb things down for me lol. But I've been trying to make a comments box for my website and following a tutorial on youtube. I'm upto about lesson 11 but i can't get past it because it doesn't work for me and the guy who posted the tutorial doesn't seem to bother replying to comments. ​Can someone take a look at my code and try help where I am going wrong? I think the problem maybe that it is a little outdated. I've already changed the ajax part from the tutorial, but it's still not working right. The console is telling me that it is a problem with : comment_insert( jQuery.parseJSON(data)); ​Thanks.
  6. hello im new to the website and web programming in general, im in need of assistance with your w3schools official AJAX live search tutorial, i've copied the code to the right files, livesearch.php and index.html, which are placed in my htdocs folder and the apache server is running well. I know my code has css issues but i need to fix something else, mainly this: This is my search form, located in a table, inside a div tag: After i type in a single letter this happens: The search box disappears, instead of auto completing the word as long as i type. And even these results are shown below the "A7 Embedded PC" image, even tho my form has a z-index set to 9999. This is my livesearch.php code: <?php $xmlDoc=new DOMDocument(); $xmlDoc->load("links.xml"); $x=$xmlDoc->getElementsByTagName('link'); $q=$_GET["q"]; if (strlen($q)>0) { $hint=""; for($i=0; $i<($x->length); $i++) { $y=$x->item($i)->getElementsByTagName('title'); $z=$x->item($i)->getElementsByTagName('url'); if ($y->item(0)->nodeType==1) { if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q)) { if ($hint=="") { $hint="<a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } else { $hint=$hint . "<br /><a href='" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" . $y->item(0)->childNodes->item(0)->nodeValue . "</a>"; } } } } } if ($hint=="") { $response="Nema rezultata!"; } else { $response=$hint; } echo $response; ?> And this is my index.html code fragment that contains the form: <script> function showResult(str) { if (str.length==0) { document.getElementById("livesearch").innerHTML=""; document.getElementById("livesearch").style.border="0px"; return; } if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("livesearch").innerHTML=xmlhttp.responseText; document.getElementById("livesearch").style.border="1px solid #A5ACB2"; } } xmlhttp.open("GET","livesearch.php?q="+str,true); xmlhttp.send(); } </script> </head> <body background="images/osnovne_slike/pozadina01.gif" vlink="#0000FF" link="#0000FF" alink="#808080" style="background-attachment: fixed"> <div align="center"> <center> <table border="0" width="990" cellspacing="0" cellpadding="0" background="images/slike_index/header_home.png"> <tr> <td width="600" height="46"> <div id="livesearch" style=" height:46px; z-index: 9996; float: right;"> <form class="form2" style=" z-index: 9999" action="livesearch.php" method="get"> <input class="input2" type="search" onkeyup="showResult(this.value)" placeholder="Pretrazi.."> </form> </div> </td> and some css for the form and input: <style> .form2 { font-family: 'Open Sans', sans-serif; vertical-align: :bottom; color:#848484; width:170spx; padding:4px 4px 4px 4px; margin:8px 5px 5px 5px; line-height: 15px; border-radius:1px; background:#f2f2f2; } ::-webkit-input-placeholder { color: #acacac;} .input2 { margin:0px 1px; border:none; background-color:#fafafa; background-repeat:no-repeat; background-size:45px 45px; background-position:left center; height:19px; width:169px; vertical-align:bottom; text-align: left; font-size:16px; border-radius:2spx; } </style> I dont know what is causing the php to display all the results at once, while the code is completely copy-pasted from w3schools website. If anyone can help me with this i'd be very grateful. UPDATE: i have placed the w3schools code in separate files and ran them in a browser using my xml document and the search is running fine, something on my website seems to be preventing the autocomplete.
  7. Hi, I having problems when I execute (from a JS file) an onclick function by the class that is into an append of another JS file. My code is this: JS File1: var user_tmpl = $('<div />') .addClass('user') .append('<strong/>').find('strong').addClass('titulo').html(item.titulo) .append('<a href="#buscamedioModal" role="button" class="btn btn-danger deletebuscamedio" data-toggle="modal" id=' + item.gid + ' data-name=' + item.titulo + '>Eliminar</a>') .parent(); JS File2 (call): // Configuraciones Generales var boton_eliminar_buscamedio = ".deletebuscamedio"; // Clase // Fin de configuraciones $(document).on('ready',function(){ $(boton_eliminar_buscamedio).on('click',function(e){ e.preventDefault(); var Pid_medio = $(this).attr('id'); alert(Pid_medio); var name_buscamedio = $(this).data('name'); But it seems that it can't run the function because doesn't find the class "deletebuscamedio". Does anyone how to do this? Thank you in advance!
  8. I am trying to get data from other server and i get right response as well as below error XMLHttpRequest cannot load http://dex2y.xyrn.com/data/profiledata.json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:56711' is therefore not allowed access. Request: $.ajax({ url: "http://dex2y.xyrn.com/data/profiledata.json", async: false, dataType: "json", success: function (json) { exampleValues = json; } }); Response: { "header": "Bob's Profile", "name": "Bob Robertson", "address": "1010 Some Street, New York, NY, 10001", "phone": "(212) 555-1212", "interests": "Bob likes apples, big ones and floating ones." } and i am not able understand about this error.
  9. http://craft.minestatus.co MineStatus - Minecraft Servers MineStatus is a brand new modern minecraft server list. Personal Server Analytics Votifier Voting Sharing Profiles Comments Blogs I have recently created my second site. Tell me what you think.
  10. I read topic about Ajax at W3School. I made firstAjax.html. I attached it. Then I create ajax_info.txt from where I want to receive data and print on html page. But code not work. Please help! firstAjax.html ajax_info.txt
  11. To sum things up... I'm looking for as much reviews as possible. I've been working on minestatus for the last year now. I've come across many programming roadblocks and developments to further improve the quality, user impression, user interface, and user engagement. If you guys have any ideas on how to make my site better in any of those categories that would be amazing. Thank so much! Link to site: http://minestatus.co Site Name: MineStatus Site Description: MineStatus is a new social sharing plateform I've created. It allows users to make there own profiles, upload content, display the content. You can even share your content on MineStatus to almost any other social network without flaw. I plan on making a developer site to go along with it to share my practices with everybody. Site Owner/Developer: Myself, I am the lead developer and creator of MineStatus Network Site Address: Here is the link to the site : https://minestatus.co Extra Info: Some technologies I've already integrated: Open Graph Protocol* Twittercards* *for those who don't know here is a link, Open Graph Protocol, Twittercards.
  12. Hi, I have the below jQuery script that should list relevant country flag before the name of flag's country. The flags are named "flags", and are of PNG format. Everything is working fine, except flags are missing. I would appreciate showing me what to change in the code to make the flags appear. function createDropDown(){ var $form = $("div#country-select form"); $form.hide(); var source = $("#country-options"); source.removeAttr("autocomplete"); var selected = source.find("option:selected"); var options = $("option", source); $("#country-select").append('<dl id="target" class="dropdown"></dl>') $("#target").append('<dt class="' + selected.val() + '"><a href="#"><span class="flag"></span><em>' + selected.text() + '</em></a></dt>') $("#target").append('<dd><ul></ul></dd>') options.each(function(){ $("#target dd ul").append('<li class="' + $(this).val() + '"><a href="' + $(this).attr("title") + '"><span class="flag"></span><em>' + $(this).text() + '</em></a></li>'); }); }
  13. Hi, I am currently trying to implement the posting of a canvas image to a Twitter wall.Below, first you see the JS I came up with.What I can't figure out is how am I supposed to get the keys and tokens provided in the PHP function below that code. Such PHP function is contained in the uploadFile.php file.JS: var base64img = canvas.toDataURL().split(',')[1]; $.ajax({ url: "uploadFile.php", type: "POST", data: base64img, processData: false, contentType: "application/octet-stream", }).done(function(respond) { alert(respond); }); PHP: function _microsite_last_tweets($search) {define('CONSUMER_KEY', 'my key');define('CONSUMER_SECRET', 'my key');define('ACCESS_TOKEN', 'my key');define('ACCESS_TOKEN_SECRET', 'my key');$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);$content = $connection->get("account/verify_credentials");if ($search[0] == '@' && strpos($search,' ') == false) {$user = substr($search, 1);$tweets = $connection->get("statuses/user_timeline", array("screen_name" => $user, "count" => "4"));}else {$search = urlencode($search);$tweets = $connection->get("search/tweets", array("q" => $search . '+exclude:retweets', "result_type" => "recent","count" => "4"));}return $tweets;}
  14. Hello everyone, I have a question about the PHP - AJAX example (http://www.w3schools.com/php/php_ajax_php.asp). In the PHP file, there is the variable " $hint ". But what is this variable used for? Here the code: $q = $_REQUEST["q"];$hint = "";// lookup all hints from array if $q is different from ""if ($q !== "") { $q = strtolower($q); $len=strlen($q); foreach($a as $name) { if (stristr($q, substr($name, 0, $len))) { if ($hint === "") { $hint = $name; } else { $hint .= ", $name"; } } }} You are declaring $hint = "". After there is no input, that could happen to $hint. Why there is the if clause? Maybe I am blind, but I don't get it. Second questions is about this code part: echo $hint === "" ? "no suggestion" : $hint; How you can use operators without function, what does ' $hint === "" ' and what does ' : ' ?I already red the whole example more than twice... but I don't get it. A short explanation or a link to another website which is explaining these would be awesome. Thank you in advance! (By copy and pasting, the example works, but I wanna understand it)(I am not native English speaker, please excuse my mistakes)
  15. Yes I'm a newbie in AJAX '&&' JavaScript. As I'm a pupil here, I find hurdle almost in any code... There is an AJAX code with some number value in it, like 4 - 200, but I can't understand the nature of this digits or what they are indicating... function loadDoc() { var xhttp; if (window.XMLHttpRequest) { // code for modern browsers xhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.onreadystatechange = function() { if (xhttp.readyState == 4 && xhttp.status == 200) { document.getElementById("demo").innerHTML = xhttp.responseText; } You see: "== 4 && xhttp.status == 200)" ... what for? Thanks to anyone who'll reply to this 'double-dumb' question!!
  16. tech991

    Bookmark system

    Hi to all. I'm new in php development. I'm trying to do a bookmark system. I have an intern search engine that extract data from a database table build in MYSQL that show as link and the user can click on and appear es text html. I want to give the possibility to add a star button near these link and when the user click on to bookmark. I found 2 ways to do this, but I'm sure that exist more solution that can do better or not: 1- Give the possibility to the user that when click on button near the link that extract data from the database to add this on a bookmark table. 2- When the user click on button add data to a the bookmark browser with a javascript as this (http://stackoverflow.com/questions/10033215/how-do-i-add-an-add-to-favorites-button-or-link-on-my-website). I think is the easiest solution but I'm not sure what can do the correct way to this. Any advice is welcome:)
  17. Hi, i am playing a game and there is a user in chat that bothers me and other players a lot but he does not break any game rule... i was wondering if there is a way i could block or mute his text with a JavaScript if so, does anyone have a tutorial on how to code something like this? the chat have no ID but every chat message is put out like this. <table border="0" padding="0" cellspacing="0" width="100%"> <tbody> <tr> <td width="90" class="chat"> <div id="202525"></div> 2015-08-24 06:06:00 </td> <td style=""> <a href="javascript:newmsg('The Martyr','')" style="">The Martyr:</a> " so I starting to give up" </td> </tr> </tbody></table> and it looks like this in chat: 2015-08-24 06:06:00 The Martyr: so I starting to give up i was thinking i could use the user name 'The Martyr' in some way to block that user i would love to code something that would just remove the lines from the chat box. and any other line the user typed and will type. i just have no idea where to start. any kind of help would be appreciated thanks
  18. I've been making tons of progress on my vehicle fit guide. I've made a drop down box dynamically populate based on previous selections, and now I need those selections to search the xml file and return my results. My old code only searched by the vehicle year, and that returned all vehicles with the same year. I'm trying to parse my XML using multiple variables, and now can't get any results to return. how am I able to search for models, then search for years within the model? here are my code snippets below, which currently only search the whole XML file for similar years: <!DOCTYPE html><html><head><link rel="stylesheet" type="text/css" href="xmlcss.css"><script data-require="jquery@*" data-semver="2.1.4" src="http://code.jquery.com/jquery-2.1.4.min.js"></script><script type="text/javascript">jQuery(document).ready(function($){ var $xml; var make = $('#make'); var model = $('#model'); var year = $('#year'); var front1 = $('#Front_Location_1'); var frontsize1 = $('#Front_Size_1'); $.get('fitguide3.xml', function(data){ $xml = $(data); var rows = $(data).find('ROWSET ROW'); var makes = []; $.each(rows, function(index, element){ var _make = $(element).find('MAKE').text(); makes.push('<option value="' + _make + '">' + _make + '</option>'); }); makes = $.unique(makes); make.append(makes.join('n')); }, 'xml'); $('#make').on('change', function(){ var _value1 = $(this).val(); var _models = $xml.find('ROWSET ROW:contains("'+_value1+'")'); var models = []; console.log(_models); $.each(_models, function(index, element){ var _model = $(element).find('Model').text(); models.push('<option value="' + _model + '">' + _model + '</option>'); }); models = $.unique(models); model.find('option').remove(); model.append(models.join('n')); }); $('#model').on('change', function(){ var _value2 = $(this).val(); var _years = $xml.find('ROWSET ROW:contains("'+_value2+'")'); var years = []; console.log(_years); $.each(_years, function(index, element){ var _year = $(element).find('YEAR').text(); years.push('<option value="' + _year + '">' + _year + '</option>'); }); years = $.unique(years); year.find('option').remove(); year.append(years.join('n')); }); // $('#make').val() // $('#model').val() // $('#year').val() $('#year').on('click', function(){ var _value3 = $(this).val(); var finalmodel = $('#model').val(); var _front1 = $xml.find('ROWSET ROW:contains("'+_value3+'")'); console.log(_front1); <!-- $("#Front_Location_1").html(""); --> $.each(_front1, function(index, element){ var _front = $('#frontspeakers').val(); var front = []; front.push('<p>' + element + '</p>'); front = $.unique(front); front1.append(element); }); })});</script></head><body><p id="test"></p><select id="make"><option value='0'>---Select Make---</option></select><select id="model" name="model"></select><select id="year"></select><table style="width:100%"><tr><td>Front Location 1</td></tr><tr><td id="frontspeakers"></td></tr><tr><td id="Front_Location_1"></td></tr></table> And this is how my XML file is set up: <?xml version="1.0"?><ROWSET><ROW><MAKE>ACURA</MAKE><Model>CL</Model><YEAR>2001-2003</YEAR><Front_Location_1>Door</Front_Location_1><Front_Size_1>6 1/2</Front_Size_1><Front_Location_2>Sail Panel</Front_Location_2><Front_Size_2>1 </Front_Size_2><Rear_Location_1>Deck</Rear_Location_1><Rear_Size_1>6 x 9</Rear_Size_1><Rear_Location_2></Rear_Location_2><Rear_Size_2></Rear_Size_2><Other_Speakers></Other_Speakers></ROW><ROW><MAKE>ACURA</MAKE><Model>CL</Model><YEAR>1999-1999</YEAR><Front_Location_1>Door</Front_Location_1><Front_Size_1>6 1/2</Front_Size_1><Front_Location_2>Sail Panel</Front_Location_2><Front_Size_2>1 </Front_Size_2><Rear_Location_1>Deck</Rear_Location_1><Rear_Size_1>6 x 9</Rear_Size_1><Rear_Location_2></Rear_Location_2><Rear_Size_2></Rear_Size_2><Other_Speakers></Other_Speakers></ROW> This searches for them, but returns every model with the same years. Work-in-progress version located HERE Any help would be great!
  19. I used AJAX to retrieve concatenated data from a XML document. Now I need to store that data into a Javascript array. How do I do this? My Javascript Code: var SVG_Data var Retrieved_Data var Coordinate_Pair var Element_List var Counter function Setup() { SVG_Data = new XMLHttpRequest(); SVG_Data.open("GET","http://localhost:8080/exist/rest/db/apps/HTML_Student/Database_Retrieval.xq", true); SVG_Data.onreadystatechange = function () { if (SVG_Data.readyState = 4) { Retrieved_Data = SVG_Data.responseText; document.getElementById("Information").value = Retrieved_Data; Coordinate_Pair = new Array(); Coordinate_Pair.push.apply(Retrieved_Data); Element_List = new Array("Top_Ladder_Line","Middle_Ladder_Line", "Bottom_Ladder_Line"); for (Counter = 0; Counter < 3; Counter++) { document.getElementById("Information").value = Coordinate_Pair[Counter]; document.getElementById(Element_List[Counter]).setAttribute("points", Coordinate_Pair[Counter]);} } } SVG_Data.send(); } The concatenated data I received from the eXist database: "60,30 60,80 150,80 150,30", "60,130 60,80 150,80 150,130", "60,180 60,130 150,130 150,180"
  20. Hi, I have doubt in AJAX Database, In that getuser.php what should i write in the place of ajax_demo. Please anybody help me. And the link is http://www.w3schools.com/php/php_ajax_database.asp
  21. I have already created mysql table with data, this is my javascript code <SCRIPT language="JavaScript">function send_status(){var status;var Digital=new Date()var hours=Digital.getHours()if (hours>=6&&hours<8) //on timestatus = "onTime";else if (hours>=8) //late comersstatus = "late";window.alert(status);}$.ajax({type: "POST",url: "ajaxjs.php",data: status,cache: false,success: function(html) {alert(html);}});}return false;}</SCRIPT> im attempting to generate a value for user status from th above if command in js then send this string into my db using ajax which is pointing to my php page <?php// Fetching Values From URL$connection = mysql_connect("localhost", "CJroot", ""); $db = mysql_select_db("mysql_practice", $connection); if (isset($_POST['typeahead'])) {$query = mysql_query("UPDATE user_signin SET status='$status' WHERE user_name = '$typeahead')"); //Insert Queryecho "Form Submitted succesfully";}mysql_close($connection); ?> im not getting it right please any suggestions?
  22. I am trying to pass a variable from a javascript function to my php file. All I do is extract the user_name from a cookie in javascript and then use AJAX to $_POST the variable to my php file for processing. I do not use a form to submit the POST variable which I have done in the past.The problem is my $_POST array is not getting passed to the php file. I've looked here and looked at several other suggestions but none work. Do you have to submit the $_POST variable via an html form? I dont think so but maybe I'm wrong. Here is the code:Javascript - function clearDoneItems() { var user_name = getNameFromCookie(); if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } alert(user_name); xmlhttp.open("POST","todolist/clear_done_items.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send(user_name); displayHomeInformation(user_name); } PHP - <!DOCTYPE html> <html> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> <title>Clear Done Items</title> </head> <body> <?php ini_set('display_errors',1); error_reporting(E_ALL); print_r($_POST); $xml_name=$_POST['user_name']; $xml_file = $xml_name . ".xml"; echo $xml_file; /* Here we will use the The DOMDocument class functions to delete the text nodes. Format XML to save indented tree rather than one line */ $domxml = new DOMDocument('1.0'); if ($domxml->load('$xml_file') === TRUE) { $domxml->preserveWhiteSpace = false; $domxml->formatOutput = true; // Start Delete process of node echo "<br>"; $xpath = new DOMXPath($domxml); // Here we use the The DOMXPath class function evaluate to do the heavy lifting. foreach ($xpath->evaluate('//doneitems/item') as $node) { $node->parentNode->removeChild($node); } //Save XML to file - remove this and following line if save not desired $domxml->save('alan.xml'); echo "<strong>XML Document updated.</strong>"; } else { echo " <strong>Error in loading XML file:</strong>"; echo "<br>"; print_r(error_get_last()); } ?> </body> </html> >Errors on php page:Notice: Undefined index: user_name in /var/www/bb/todolist/clear_done_items.php on line 160Warning: DOMDocument::load(): I/O warning : failed to load external entity "/var/www/bb/todolist/$xml_file" in /var/www/bb/todolist/clear_done_items.php on line 24 I thought from reading up on AJAX the POST variable is set from the three commands xmlhttp.open,.setRequestHeader and .send. Dont these take the place of the POST action in an html form?
  23. Since some webpages of W3Schools discuss which browsers (e.g. Google Chrome, Internet Explorer) support certain features, I think that W3Schools should note in its jQuery AJAX tutorials that Google Chrome cannot be used to import files (e.g. .html files) from one's own hard drive, whereas Internet Explorer and Mozilla Firefox can. This would have saved me much time that I spent finding out the hard way, and based on other online forums, other people seem to be confused by Google Chrome's incompatibility and do not know the reason.
  24. when i select some thing in bill.php ,it ajax call and get value from get user.php then it display content on bill.php the page but how could i hold those value in a variable in bill.php page for further use in php bill.phpgetuser.php
×
×
  • Create New...