Jump to content

Search the Community

Showing results for tags 'ajax'.



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

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

Found 117 results

  1. Trace7r

    JS PHP Trouble

    Ok i'm totaly new here, I play with some code when I have time for it... But I'm a little confused, it seems that the new ajax way is coded as $.ajax but that I don't understand yet, Because i'm adjusting some existing code I have to go from one php file to another over js the old way... So I have a php file where I echo a div with an input as type="text" and id="txtnameposition", in the same div I have a button who is calling the function closeandmail in the JS file. In the JS file I get de input of the textbox as: var jsName = document.getElementById("txtnameposition").value; When I put an alert(jsName); inside the JS file I do get the input value, so passing values from the first php file to the js file is no problem.... BUT, to send this all to the next PHP file I used next code in the JS file: function getHTTPObject(){var xhr = false;//set to false, so if it fails, do nothingif(window.XMLHttpRequest) {//detect to see if browser allows this methodvar xhr = new XMLHttpRequest();//set var the new request} else if(window.ActiveXObject) {//detect to see if browser allows this methodtry {var xhr = new ActiveXObject("Msxml2.XMLHTTP");//try this method first} catch(e) {//if it fails move onto the nexttry {var xhr = new ActiveXObject("Microsoft.XMLHTTP");//try this method next} catch(e) {//if that also fails return false.xhr = false;}}}return xhr;//return the value of xhr}function closeandmail(){var jsName = document.getElementById("txtnameposition").value;httpObjectMail = getHTTPObject();if (httpObjectMail !== null) {httpObjectMail.open("GET", "mail.php?"+ "Name=" + jsName);httpObjectMail.send(null);}httpObjectMail = null;} And in the second PHP file I put next code: $Name = $_GET['Name']; echo 'Name = '.$Name;$MailMessage = 'The name = '.$Name;$to = 'mail@mail.com';$subject = 'The name = '.$Name;$headers = 'From: mail@mail.com'.'rn'.'X-Mailer: PHP/' . phpversion();mail($to, $subject, $MailMessage, $headers); The echo only shows "Name = " and no value, so can someone please tell me what is wrong in this code? because I did try a lot of things but it didn't work so far. Greetings Trace7r.
  2. Hi, I have two pages. The first page has two links, when a user clicks on one of them then s/he can view some information. I have used an image viewer taken from http://projects.sebastianhelzle.net/jquery.rondell/examples/carousel.html and I have set it according to my needs. the code of the first/main page is: <html><head><title>Animals</title><script>function loadXMLDoc(){var xmlhttp;if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { document.getElementById("rondellCarousel").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","second.html",false);xmlhttp.send();}</script></head><body> <a href = "#" onClick = "loadXMLDoc();">Αnimals</a><br /> <br /><a href = '#' >Cars</a><div id = "rondellCarousel" class = "false"><!-- I expect to see the image viewer here :/ --></div></body></html> The code of the second page is: <!DOCTYPE html><html class="no-js"> <head> <link rel="stylesheet" href="scripts/jquery.rondell.css" type="text/css" media="all" title="Screen"> <script src="scripts/modernizr-2.0.6.min.js"></script> <title></title> </head> <body> <br> <div id="rondellCarousel" class="hidden"> <a target="_blank" rel="rondell_1" href="images/band.jpg" title="My favourite band"> <img src="images/band_small.jpg" alt="Band" title="My favourite band"> <h5>Awesome concert</h5> <p>My favourite band.</p></a><a target="_blank" rel="rondell_1" href="images/dog.jpg" title="My dog"><img src="images/dog_small.jpg" alt="Dog" title="My dog"> <h5>My dog</h5> <p>Standing in front of a glass door and wants in.</p></a><a target="_blank" rel="rondell_1" href="images/cat.jpg" title="My cat"><img src="images/cat_small.jpg" alt="Cat" title="My cat"> <h5>My cat</h5> <p>Sleeping...</p></a><a target="_blank" rel="rondell_1" href="images/boar.jpg" title="Boar"><img src="images/boar_small.jpg" alt="Boar" title="Boar"> <h5>Dead boar on the wall</h5> <p>Hanging around.</p></a><a target="_blank" rel="rondell_1" href="images/snow.jpg" title="Snow"><img src="images/snow_small.jpg" alt="Snow" title="Snow"> <h5>Winter wonderland</h5> <p>The german alps.</p></a><a target="_blank" rel="rondell_1" href="images/rabbit.jpg" title="Rabbit"><img src="images/rabbit_small.jpg" alt="Rabbit" title="Rabbit"> <h5>Bunny</h5> <p>In my brothers garden.</p></a><a target="_blank" rel="rondell_1" href="images/trash.jpg" title=""><img src="images/trash_small.jpg" alt="Trash" title="Trash"> <h5>Trash</h5> <p>Somewhere in the USA.</p></a></div> <script src="scripts/jquery-1.9.1.min.js"></script> <script src="scripts/jquery.rondell.js"></script> <script type="text/javascript">(function() { $(function() { var carousel; carousel = $("#rondellCarousel > *").rondell({ preset: "carousel" }); $(".resize-button").click(function(e) { e.preventDefault(); return carousel.fitToContainer(); }); return $.ajax({ url: "http://www.wookmark.com/api/json", dataType: "jsonp", success: function(data, text, xhqr) { var item, rondellContent, _i, _len, _ref; if (text === "success") { rondellContent = ""; _ref = data.slice(0, 25); for (_i = 0, _len = _ref.length; _i < _len; _i++) { item = _ref[_i]; rondellContent += " <a href="" + item.image + "" title="" + item.title + " @ " + item.url + "" target="_blank" style="display:none"> <img src="" + item.preview + "" title="" + item.title + "" width="" + item.width + "" height="" + item.height + ""/> </a> "; } return $("#rondellCubic").html(rondellContent).children().rondell({ preset: "cubic" }); } } }); });}).call(this);</script> </body></html> The problem is that, even if Ajax works without getting any problem, the pictures are not presented like a "carousel image viewer". If I put directly the second page in the address bar and browse it, I see the images as I wish (like a carousel image viewer with next/prev arrows). Can anyone help with that? Thank you in advance.
  3. Hi, I am using the following code to display products and prices when dropdown selected. What I need to do though is for a certain table to be selected if the visitor to my site clicks on a particular link. For example if the visitor clicks a link for A2 Leaflets on my home page, I need the drop down to display A2 Leaflets products and prices when the new page loads. Can anyone suggest a way this can be done? I am guessing it only requires something simple to be added to the existing ajax code, I just dont know where to begin looking? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script type="text/javascript">function showUser(){var user = document.getElementById("user").value;var type = document.getElementById("type").value;var finish = document.getElementById("finish").value;if (finish=="") { document.getElementById("txtHint").innerHTML=""; return; }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 (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","getuser.php?q="+user+"&t="+type+"&f="+finish,true);xmlhttp.send();}</script><link rel="stylesheet" type="text/css" href="dropdown_form.css" media="screen" /></head><body><div id="prices_dropdown_form"><form id="dropdown_form"><select id="user"><option value="">Select Leaflet Type</option><option value="1">A2 Leaflets</option><option value="2">A3 Leaflets</option><option value="3">A4 Leaflets</option><option value="4">A5 Leaflets</option><option value="5">A6 Leaflets</option><option value="6">A7 Leaflets</option><option value="7">210x198 Leaflets</option><option value="8">210x396 Leaflets</option><option value="9">55x85 Leaflets</option><option value="10">1/3 A4 Leaflets</option><option value="11">6pp A4 Leaflets</option><option value="12">6pp A5 Leaflets</option></select><select id="type"><option value="">Select Paper Type</option><option value="1">120 Laser</option><option value="2">130 Gloss</option><option value="3">130 Silk</option><option value="4">170 Bond</option><option value="5">170 Gloss</option><option value="6">170 Silk</option><option value="7">250 Gloss</option><option value="8">250 Silk</option><option value="9">300 Bond</option><option value="10">350 Silk</option><option value="11">400 Silk</option><option value="12">400 Silk GLam1</option><option value="13">400 Silk GLam2</option><option value="14">400 Silk MLam2</option></select><select id="finish" onchange="showUser()"><option value="">Select Finish Type</option><option value="1">Flat</option><option value="2">Fold</option><option value="3">Creased & Flat</option><option value="4">Creased & Fold</option></select></form><br /><div id="txtHint"><b>Product Info & Prices</b></div></div></body></html>
  4. unplugged_web

    IE not updating

    I have a url (on a separate server with a different domain name) that gives me various parameters I need. I've managed to get the results, but for some reason it doesn't show any results at all in IE and I'm not sure why. It works in every other browser, but just not IE. I've checked the console and there's no errors at all, I've also used jslint.com to check the js code and that's all fine too. While I'm testing this I've removed everything else in the file so that there's nothing that can conflict with it. This is what I'm using to get the results. I have a separate js file that contains this: /*jshint -W061 */function call(url, parameters, callback) { "use strict"; $.ajax({ type: 'POST', url: url, data: parameters, success: function(data) { callback(data); }, cache: false } );} function loadJackpots() { "use strict"; call("https://www.domain.com/passkey", { JL: 0 }, function(data) { var divIdentifier, obj = eval('(' + data + ')'); $.each(obj.JL, function() { divIdentifier = ""; switch (this.gameID) { case 2: divIdentifier = "#snap"; break; case 5: divIdentifier = "#dominos"; break; case 1000: divIdentifier = "#chess1"; break; case 1001: divIdentifier = "#chess2"; break; case 1002: divIdentifier = "#chess3"; break; } if (this.gameID >= 1000) { switch (this.stakeID) { case 4: divIdentifier += "_50c"; break; case 5: divIdentifier += "_1d"; break; case 7: divIdentifier += "_2d"; break; case 9: divIdentifier += "_2d"; break; } } if (this.gameID === 1000) { switch (this.subID) { case 0: divIdentifier += "_1"; break; case 1: divIdentifier += "_2"; break; case 2: divIdentifier += "_3"; break; } } $(divIdentifier).html("$" + this.jackpot); }); } );} I use this to actually load the values: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script><script type="text/javascript"> $(function() { loadJackpots(); }); </script> And to display the results I'm using this: <div id="chess1"><div id="chess1_50c">$1466.85</div><div id="chess1_1d">$1641.11</div><div id="chess1_2d">$378.04</div></div> <div id="chess3"><div id="chess3_50c">$303.86</div><div id="chess3_1d">$523.02</div><div id="chess3_2d">$1473.72</div></div> </div><div style="float: left; margin: 194px 0 0 185px;"><div id="chess2_1"><div id="chess2_50c_1">$195.26</div><div id="chess2_1d_1">$154.37</div><div id="chess2_2d_1">$193.76</div></div><div id="chess2_2"><div id="chess2_50c_2">$146.84</div><div id="chess2_1d_2">$119.58</div><div id="chess2_2d_2">$145.86</div></div><div id="chess2_3"><div id="chess2_50c_3">$2.96</div><div id="chess2_1d_3">$19.25</div><div id="chess2_2d_3">$121.89</div></div> </div></div><div style="height: 80px;"><div id="snap"><div id="snap_jp">$862.16</div></div> <div id="dominos"><div id="dominos_jp">$2823.18</div></div> I've also tried this but to no avail, it just gave me an error saying obj is undefined: <div id="dominos"><div id="dominos_jp">$2823.18</div><script language="javascript">document.getElementById("dominos_jp").HTML=obj.JL[1].jackpot</script></div> I'd be really grateful for any help with this as I've tried everything to get it sorted, but no matter what I do it just won't work in IE. I read something about Ajax doesn't allow cross domain requests but I don't know how to rectify this - the values come from a url that is on another domain and I can't change that.
  5. Hello all,I have tried so many things to get this to work but to no avail, can someon eplease help me out here with a simple script for n XML steam feed.http://api.steampowered.com/ISteamUserStats/GetGlobalAchievementPercentagesForApp/v0002/?gameid=221380&format=xml OK NOW THE ISSUE IS:I have a blank webpage which I have placed the above link into, I simply want the contents of the XML feed from the link to appear in mypage.......How do I make the contents of that url appear on the same page??SO I NEED THE SMALL SCRIPT OR HTML CODE TO DO THISAlso I would like to have the background a certain colour and use a certain font like 12point arial with bold headings and lower case text.Can someone please provide me with the html to allow this XML feed to appear on my webpage with a different colour background, arial 12pt font inbold and lowercase____________________________________________________________________________I RECEIVED A REPLY TO THIS POST AND THEY ADDED THIS:It's a little hard to tell from what you wrote. But, I think what you are looking for is an AJAX script to pull in the XML,then CSS can take care of the formatting.Look up how to process a XMLHttpRequest in javascript (or another scripting language). That will let you put the XML file into an array. Then,you can use (javascript) document.write() to put the pieces on your page.______________________________________________________________________________SO this being said do I need a javascript code in the page to show the XML Feed with formatting, what would this code be, this is the magicalquestion :)Could someone please please help me..........With regardsMathew
  6. Hello gentlemen.As continue to my previous post, I got some important question.Lets imagine that there is a site with around 50 000 users at the same time on it, this users is on different pages of this site (10-20 users on page) and on each page they must exchange small amounts of data with each other in real-time (like chat room for example)How can i do this? there is a way to do this wit AJAX by holding request from user to database on server, until server gives answer... but that way it will mean that 50000 request will be opened all over the site on the same time. Isn't that gonna be insane load on the server, and no hoster will allow this? I mean i can't even understand what does that hanging requests means in terms of load on the server, the data, transfered, going to be extremely small, in what values can even evaluate this load? It will eat up server's RAM, or handling 50000 hanging requests will make effect on processor's performance... it's really unclear for me. I was thinking about APE project http://www.ape-project.org/download/ , but then i need to find hoster that will support APE servers (well or am i misunderstanding something?)...Or there is a way to handle this without any insane loads and without using some side servers e.t.c?
  7. cfajardo

    AJAX Database with ASP Page

    Hi, I need to fill a drop-down box from another drop-down box in an ASP using AJAX, I was following the AJAX Database example, but I don't get the data, so don't know what am I doing wrong, could anyone please help me trying to figure out what's wrong or if you have an example of how to fill a drop-down box once you change the value of another drop-down box? here is my code: AJAX.JS function showSubject(str){var xmlhttp;if (str=="") { document.getElementById("materias").innerHTML=""; return; }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 (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("materias").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","materiaslista.asp?q="+str,true);xmlhttp.send();} MATERIASPAGE.ASP<% response.expires=-1 Set base=Server.CreateObject("ADODB.Connection")base.ConnectionString = "DSN=acc"base.Open strSql="Select * from tblMaterias where Carrera="strSql=strSql & "'" & request.querystring("q") & "'" set rsMat=Server.CreateObject("ADODB.recordset")rsMat.Open strSql,base response.write("<table>") do until rstMat.eof for each x in rstMat.Fieldsresponse.write("<tr><td><b>" & x.name & "</b></td>") response.write("<td>" & x.value & "</td></tr>") next rstMat.movenext loop response.write("</table>") %> STUDENTS.ASP I have: <script type="text/javascript" src="ajax.js"></script> <form method="post" action="save_data.asp?ac=1" name="Form1"><tr><td class="style5"><span lang="es-pa"><strong>Carrera</strong></span>:</td> <td class="style5"> <select name="carrera" onchange="showSubject(this.value)" > <option value="">Seleccione una carrera!</option> <%while not rstCar.eof%><option value="<%=rstCar.Fields("id")%>"><%=rstCar.Fields("carrera")%></option><%rstCar.MoveNextwend%></select></td></tr><tr> <td class="style5"><strong>Materias:</strong></td> <td class="style5"> <div id="materias">TEXTO</div></td></tr></form> Thanks
  8. Hi, I'm trying to build a "hello world" AJAX / PHP application: AJAX code: <html><head> <title></title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script> $(document).ready(function(){ //Requete AJAX var resultat = $.ajax({ url: "serveur.php", async: false }); alert(resultat.responseText); }); </script></head><body></body></html> PHP code: <?phpecho 1;?> I would expect the result of the alert() function to be "1", while it is:<?phpecho 1;?> So as far as I understand, the server-side code is not interpreted, and that's surprising to me since it is interpreted when I run it separately, without calling from AJAX. May I ask for your help? Thanks, Mathieu
  9. I am working on a website for a video game streamer I watch and sometimes he plays with other streamers and viewers want to watch them both or in some cases more than 2, all play at the same time. So there are sites that do "dual streams" that will allow you to show both videos on the same page. My idea was to make something similar but scale-able to however many streams are needed. So far I have js functions with all the HTML needed add the video player but not sure how i would add a new video to the page without having to refresh. I am using the document.getElementByID('streams').innerHTML = mainStream()+newStream(); right now to manually show the primary stream and a image to click on to add another stream. function mainStream() { result = "\t<div id=\"stream1\" class=\"td stream\">\n"+ "\t\t<object type=\"application/x-shockwave-flash\" class=\"stream-object\" data=\"http://www.twitch.tv/widgets/live_embed_player.swf\" width=\"100%\" height=\"100%\" style=\"visibility: visible; \">\n"+ "\t\t<param name=\"allowFullScreen\" value=\"true\">\n"+ "\t\t<param name=\"allowScriptAccess\" value=\"always\">\n"+ "\t\t<param name=\"allowNetworking\" value=\"all\">\n"+ "\t\t<param name=\"wmode\" value=\"transparent\">\n"+ "\t\t<param name=\"flashvars\" value=\"hostname=www.twitch.tv&channel=the_black_russian&auto_play=true&start_volume=100\"></object>\n"+ "\t</div>\n"; return(result); } function newStream(streamNum) { result = "\t<div id=\"stream"+streamNum+"\" class=\"td newStream\" onclick=\"getStream()\">\n"+ "\t\t<img src=\"lib/new_stream.fw.png\" style=\"width:100%; height:100%\" alt=\"new stream\" title=\"Click to open a new stream...\" />\n"+ "\t</div>\n"; return(result); } In hard code it would look like this when printed: <div id="streams"> <div id="stream1" class="td stream" style="width: 301px; height: 169.3125px;"> <object type="application/x-shockwave-flash" class="stream-object" data="http://www.twitch.tv/widgets/live_embed_player.swf" width="100%" height="100%" style="visibility: visible; "> <param name="allowFullScreen" value="true"> <param name="allowScriptAccess" value="always"> <param name="allowNetworking" value="all"> <param name="wmode" value="transparent"> <param name="flashvars" value="hostname=www.twitch.tv&channel=the_black_russian&auto_play=true&start_volume=100"></object> </div> <div id="stream2" class="td newStream" onclick="getStream()" style="width: 301px; height: 169.3125px;"> <img src="lib/new_stream.fw.png" style="width:100%; height:100%" alt="new stream" title="Click to open a new stream..."> </div></div> What I am looking to do is when someone triggers getStream() for it to add another stream and list the newStream() code last. This would make the new stream #2 and push the open a new stream part to stream #3. I also would like to add in functionality to close a specific stream. Any help is much appreciated! If I did not explain enough please let me know I will try my best to fill in any details I may have missed.
  10. w3schoon

    JQuery $.ajax() Basics

    Nice be with you everyone! I'm planing to use JQuery $.ajax() method to delete 1 row of my database. While searching I found this on the web... $.ajax({ type: 'get', url: '/examples/delete.php', data: 'ajax=1&delete=' + $(this).attr('id'), success: function() { parent.fadeOut(300,function() { parent.remove(); }); } }); I have questions: 1. What is the difference of post & get in the type: ?2. What is the usage of 'ajax=1&delete=' in the data: ?3. If there is success: how about if not success, I mean error handler? Thank you.
  11. w3schoon

    How to fix Ajax Error 404?

    Nice be with you everyone! Problem:Every time I click delete (database) button it always trigger 404: and respond "Could not contact server". Questions:1. What is Error 404?2. And how to fix it to run Ajax successfully? Here's my code: var parent=$(this).closest("tr"); $.ajax({ type:'get', url:'javascripts/delete.php', data:'ajax=1&delete='+$(this).attr('id'), statusCode: { 404: function() { $("#alert").html('Could not contact server.'); }, 500: function() { $("#alert").html('A server-side error has occurred.'); } }, error: function() { $("#alert").html('A problem has occurred.'); }, success:function(){ $("#alert").html('Successful!'); parent.fadeOut(300, function(){ parent.remove(); }); } }); Thank you!
  12. Currently I'm learning Ajax with Java.The innerHTML method works when I'm retrieving simple string data from the servlet, and when I need to update only one HTML element.Since I have the need to update more HTML elements it occurred to me that I can use JSON object with several properties (HTML tag data for each element needed updating).After trying that I've noticed that innerHTML method doesn't work, when I try to process the retrieved data in the Callback function.My question is, why is this happening?Did someone had a similar problem when using JSON with Javascript.Just for the record, when I use innerText method I successfully update the HTML elements with JSON properties data, only they update as text and that's what I don't need. (See the video) Thank You.
  13. Nice be with you everyone! Can you give some tutorials about Validates Form using PHP with Ajax & JQuery? I red that it is the best practice...
  14. will71110

    Using MySQL and PHP Query

    Hello. I am experimenting with PHP and MYSQL because I am new at it. I am trying to use AJAX to create a query into a database that I have. It isn't working. I'm sure I've made a mistake but I cant seem to find it. Someone please look over my code and see if there is something I am missing. I know my database is working because I use it to log in. It has to be in my code. The results I get from this is blank. The AJAX does call on the PHP correctly because I do get an echo back, but only because the $results isn't working. query/users.php <?phpinclude('includes/config.inc');$sql = "SELECT * FROM user";$result = mysql_query($sql,$con);if($result){echo "Username <br>";}else{echo "Nothing Found: ". mysql_error();}while($row = mysql_fetch_array($result)){echo $row['username'];echo "<br>";}mysql_close($con);?> /includes/config.ini //Real info has been removed for security <?php$hostname = 'hostname';$dbname = 'databank';$username = 'username';$password = 'password';$con = mysql_connect($hostname, $username, $password) or DIE('Connection failed');mysql_select_db($dbname, $con) or DIE("Database isnt available");?> admin.php <?phpsession_start();include('includes/config.inc');if (!isset($_SESSION['username'])) {header('Location: index.php');}?><script type="text/javascript">function q(url){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 (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("q").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET",url,true);xmlhttp.send();}</script><HTML><head><link rel="stylesheet" type="text/css" href="../css/secure.css"><title>Admin Page</title></head><body><table> <tr> <td class='seven'></td> <td class='fi'>Welcome: <?php echo $_SESSION['username']?> </td> <td class='fi'><a href="logout.php">Logout</a></td> </tr></table>This is the ADMIN page<br><input value="Get Users" type="submit" onclick="q('query/users.php')"><div id="q"></div></body></HTML>
  15. aneeb

    Send JSON through AJAX

    Hey Everyone! i have generated JSON from HTML form data, now i want to send that JSON to a PHP page. I have written this javascript. var jsondata;$.fn.serializeObject = function(){ var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o;};$(function() { $('form').submit(function() { jsondata = $('#result').text(JSON.stringify($('form').serializeObject())); return false;});}) Please help me i am new to this..
  16. Ok, I have an interesting problem. I'm using AJAX to pull information from in an XML file. Every thing works, however, quotes are giving me issues. I have the: <SOURCE>llSay("hello world",0)</SOURCE> as one of my elements in the XML. When I pass this in my javascript to the HTML, the source ends up looking like this: <input value="x" onchange="checkState('d4', this, 'llSay(" hello world",0)' ,'its triggered by the state')"> and I need it to look like this: <input value="x" onchange="checkState('d4', this, 'llSay("hello world&quot,0)' ,'its triggered by the state')> so I tried this: <SOURCE>llSay("hello world",0)</SOURCE> and I end up with: <input value="x" onchange="checkState('d4', this, 'llSay("hello world",0)' ,'its triggered by the state')"> What can I do to the XML file to make it pass " as it. I tried \" but I end up with \" as the results.
  17. athenastar17

    Which language to use?

    Hey, everyone. I'm new to the forums, but not to W3 Schools or programming in general. I've spent the past 3-4 days combing the tutorials for asp, asp.net, ajax, php, html5, cshtml, etc. and learned way more about each than I'm probably ever going to need. At this point, I'm only inches closer to completing my project than when I started looking through these (though I suppose I'm a better web dev for it), and there is only one question in my mind - which language should I actually be looking at to make this work? It seems to me after looking through each one individually that any language detailed on W3 Schools will work for what I need, but some of them may be easier than others. That's not something I can determine myself without knowing each language like the back of my hand, however. I'd like to ask your opinions - especially people who have actually used these tools to do similar things. I'd like to do something similar to Comicpress for Wordpress, but less bulky, and friendlier to mixed media. On one hand, if I utterly fail at this, I could just use Comicpress, but I'd like more control over the system and I'd like to only have the files and the processes and features that are necessary to do what I want to do. I've gotten a lot of recommendations from other artists in the same boat to write my own site if I can, rather than using a Wordpress engine. (I'd also like to just see if I can do it, improve my skills in web dev, etc...which is really what most of us are here for, right?)The layout I'm going for is extremely similar to what I would get out of Wordpress for comics.... The most important things are the back/forward and the comments (per strip) - and of course the ads, which will put food on my table, but I'm not too worried about those - those will come with Comicpress if I have to throw in the towel. The part that I really want to be able to include that Comicpress won't be very good at is the tiny audio bar underneath the comic strip. The only thing I regret about comics in general is that you must rely on lighting, etc. to set mood. I know there are Wordpress widgets for this, but none exactly what I had in mind. What I would really like to do is have music attached to the comic that does the following....1) continues to play over several strips as a "soundtrack" (and loops, and plays automatically). The strips are so short that restarting the music for each one would be less than ideal, and would get annoying pretty quickly. This also means the music should not be a playlist, but a single song.2) changes the song automatically at predefined scene changes, when the user hits the back/forward buttons and changes the comic. The music file for each comic should be stored/associated with it somewhere.3) can be turned off (or there's a different "version" of the site where music is not enabled) because this could be very annoying to some users that prefer to read their comics in peace and quiet. It's a cool feature, but certainly not for everyone. I'll be happy if I can get it working and then make a separate page entirely where that functionality is disabled, but it would be nice if it was an switch/checkbox/button on the page that could be cached to that user. Things I've tried...At first, I thought about using AJAX to reload the strip, ads, and comments, and only load the music when the strip changes. Still unsure whether this is the correct/easiest method.Then I found a web widget that "autoresumes" play when a page reloads, which I would be fine with, but I believe it may be impossible to tell it not to resume, and to stop playing the song it's on and play something different. It seems to behave like a playlist as well, from my understanding.I thought about having a database for the strips, where an image file, page ID, (chapter/volume number, commentary, etc etc), and music file is defined. When the music file defined on the page to be displayed is different than what is playing, the music changes. But it does not, under any circumstance, change to a new song in the middle of a strip, as a playlist would (which is most wordpress and audio widgets in general).Other things I'm unsure of (because I haven't tried it yet) are how to connect the list of comments to each particular strip individually, and how to load new comics, comments, and ads without creating a new page file for each and every one. I want to make it as quick and easy as possible to add new content without having a billion html files like back in the dark ages, but I still want users to be able to link to a specific page. TLDR; Again, I've read MOST of the tutorials and understand most of them, and I still have no idea WHICH route I should be looking into and researching further in order to make something like the above. A simple point in the right direction (so I can continue the Google search and know for certain there's a light at the end somewhere) is all I ask, but if anyone does have specific answers to these questions, I'd be happy to have them. I just don't want to start looking into, say, classic ASP, when I should be using PHP or something, and find out only after weeks of work that I should have gone down a different route.Thank you for your help!!
  18. will71110

    AJAX

    So I have this project I'm suppose to be doing. It's to make a web page using AJAX to update a page every 5 seconds, stop/start when a button is pushed, and dynamically update when the back end XML is updated. The problem I have is that it isn't updating (FTP) right after I change the XML. It takes like 5 to 10 mins for it to actually update. here is the code: <script type="text/javascript">var z = 0;var repeatIDfunction halter(url){ if (repeatID){ clearInterval(repeatID) repeatID = null document.getElementById('ChangeMe').innerHTML = "Message paused"; } else{ loadXMLdoc(url) }}function loadXMLdoc(url) { var xmlhttp var txt if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("microsoft.XMLHTTP"); } repeatID = window.setInterval(function() { xmlhttp.open("GET", url, true); xmlhttp.send(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { x = xmlhttp.responseXML.documentElement .getElementsByTagName('message'); if (z < x.length) { xx = x[z].getElementsByTagName("content") txt = xx[0].firstChild.nodeValue z += 1 if (z == x.length){ z = 0 } } } document.getElementById('ChangeMe').innerHTML = txt; } }, 1000);}</script> Is it in my script or is my browser doing something it's not suppose to??
  19. I'd like to access a database that is on the client side via Javascript and was wondering how to best go about this. I was thinking it may work to use Ajax to call a C# data application, but wondered if that would be most efficient. I suppose PHP would be another alternative, but I prefer working in C# if I can. Thanks!
  20. Does anyone know what event is fired when a Dropdown entry is selected for an input of type Textbox? I am using the AutoComplete Widget of the jQuery UI and I am attempting to perform some functions on the style of the Textbox when a user selects one of the entries. P.S. I'm also wondering is there a way a can track which events are being triggered as I use controls on the page perhaps maybe Google Chrome Developer Tools or FireFox Develpor Tools have this functionality?
  21. deadpickle

    TypeError for setRequestHeader

    I'm pretty new to javascript/ajax/php/html so bear with me.I am Trying to use ajax to connect to a database. The reason I am using ajax is so I can dynamically update the webpage as information is gathered about the database. So far I have is setup so that when a button is clicked: <input type="button" value="Login" onclick="sqllogincheck(this.form)"> a function is ran that will connect up to the database server side: <html><head><title>High Plains Regional Climate Center</title><link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>"><?php wp_head(); ?></head><!--All functions for pages--><script>//login and get mysql tables, update table status viewfunction sqllogincheck(frm) {var xmlhttp; //All fields must be fullif (frm.sqlusr.value == "" || frm.sqlhost.value == "" || frm.sqlpwd.value == "") { alert("Missing Fields!");}//use AJAX to setup a query to the serverelse { xmlhttp=new XMLHttpRequest(); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("dbstatus").innerHTML=xmlhttp.responseText; } } //send POST request to server xmlhttp=open("POST","citools/login.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send("sqlusr=" + frm.sqlusr.value + "&sqlhost=" + frm.sqlhost.value + "&sqlpwd=" + frm.sqlpwd.value); //alert("Username: " + frm.sqlusr.value + "\nHost: " + frm.sqlhost.value + "\nPassword: " + frm.sqlpwd.value)}}</script><body><div id="wrapper"> <div id="header"> <img src="<?php bloginfo('template_directory'); ?>/images/headers/top_logo.jpg" alt="HPRCC"> <!--<div id="menu"> <?php wp_nav_menu( array( 'theme_location' => 'header-menu', 'container_class' => '') ); ?> </div>--> <?php shailan_dropdown_menu(); ?> <h1 id="pagetitle"><?php wp_title(); ?></h1> </div> When I test this code out I get the error "Uncaught TypeError: Object [object Window] has no method 'setRequestHeader'". I have the vague idea that this means there is no 'setRequestHeader' method in the xmlhttp object, but im not sure how to correct it.Just a bit more info here. I'm testing this page using localhost and am not sure if that has anything to do with the error. Also, I'm using Wordpress for my CMS and this is why I only posted the header here.Thanks for the help.
  22. mrhussein

    PHP AJAX (could u help me ?)

    Hello, regarding to this example in your website: this example display data from mysql database\table with parameter (dropdown list),and i do input the choices to this list,what if i want same this but the choices in the (dropdown list) come from database\table as well ? anyone can help me plz? this example containing two files as the following: 1. HTML File: <html><head><script type="text/javascript">function showUser(str){if (str=="") { document.getElementById("txtHint").innerHTML=""; return; }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 (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.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">Glenn Quagmire</option><option value="4">Joseph Swanson</option></select></form><br /><div id="txtHint"><b>Person info will be listed here.</b></div></body></html> 2. PHP File: <?php$q=$_GET["q"];$con = mysql_connect('localhost', 'peter', 'abc123');if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("ajax_demo", $con);$sql="SELECT * FROM user WHERE id = '".$q."'";$result = mysql_query($sql);echo "<table border='1'><tr><th>Firstname</th><th>Lastname</th><th>Age</th><th>Hometown</th><th>Job</th></tr>";while($row = mysql_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>";mysql_close($con);?> Thank you very much... Regards,
  23. Hello I've got a question about "AJAX Database Example" from w3schools page (linked here -> http://www.w3schools...ax_database.asp ) All works perfectly fine, but I want to adjust it to TWO select dropdowns and show the results only after the second one is selected (I pick the first select, then second one and after that results are shown). The problem is, I don't know exactly what I need to change in showUser function. Of course it needs to take 2 parameters and I have to create second select dropdown outside the function, but my knowledge about AJAX is too poor to make it work ; / Will somebody help me ? ; ) If already there is a topic about the same issue I'm really sorry, but I've got some problems with search module on this forum. Kinda doesn't show any results ;x
  24. I have an xml blog and a javascript file i am trying to use to publish this blog to a website with. I am just testing to see if AJAX is working at all because i have been having issues with this for a day now. Here is the Javascript code: function blog(){var xhr = new XMLHttpRequest(); xhr.onReadyStateChange = function(){if(xhr.readyState == 4 && xhr.status == 200){var xmldom = xhr.responseXML;alert(xmldom.documentElement);}} xhr.open("GET","blog.xml",true);xhr.send();} Here is the xml code: <?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><item><title>hello</title> <link>www.google.com</link> <description>world</description></item><item><title>hello</title> <link>www.google.com</link> <description>world</description></item><item><title>hello</title> <link>www.google.com</link> <description>world</description></item></channel> </rss> Finally, here is the HTML code: <div id="blog"><h4>News Updates</h4><script type="text/javascript" src="blog.js" async></script><button type="button" onclick="blog()">click me</button></div> I have it set up to where the button in the HTML code has the onclick event listener that calls the javascript "blog()" function. the problem is that i never does anything NO MATTER WHAT I DO. it is always unresponsive. I never get a single alert box no matter what i make the script do inside the onreadystate function.
  25. sepoto

    Twitter.

    I have this code that does some AJAX to go back into my database and extract an array of bars. I have developed the code to change one of my div's to display all the data for each bar. In addition to displaying the data I also need to modify the contents of #latestFromDSGbuffer to contain a twitter feed of 5 tweets each per bar that was queried. I have tried a number of samples but for some reason I am able to get the twitter samples working in a sandbox but when I try to integrate that code things don't seem to be working out. I don't know if maybe that is because I was trying to call $.ajax(); inside of the callback function from another $.ajax(). Maybe the design needs to be modified? Maybe I should use some DOM storage to store barLocations? I'm wondering what to do with it. All of the data is located in "barLocations". Although I have attempted to make "barLocations" "global" I am not able to access it from within button.onclick where it is showing as "undefined". $.ajax({ url: 'ajax.php', data: { lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng(), radius: radius }, type: 'post', success: function(output) { barLocations = $.parseJSON(output); //alert(obj[0].lat); /* So now that we have the JSON encoded array it has to be displayed into one of the div's probably below the map someplace */ var newInnerHTML = ""; for(var i = 0; i < barLocations.length; i++) { newInnerHTML = newInnerHTML + "<strong>" + barLocations[i].company + "</strong></br>"; newInnerHTML = newInnerHTML + barLocations[i].first_name + " " + barLocations[i].last_name + "</br>"; newInnerHTML = newInnerHTML + barLocations[i].street_address1 + "</br>" + barLocations[i].street_address2 + "</br>" + barLocations[i].city + "</br>"; newInnerHTML = newInnerHTML + "Phone: " + barLocations[i].phone_number + "</br>"; newInnerHTML = newInnerHTML + "Email: " + barLocations[i].email + "</br>"; newInnerHTML = newInnerHTML + "Website: " + barLocations[i].website + "</br>"; newInnerHTML = newInnerHTML + "<a href=\"standardprofile.php\" target=\"_blank\">Profile page >>>></a>"; newInnerHTML = newInnerHTML + "</br></br>"; } for (i = 0; i < barLocations.length; i++) { var markerImage = 'image/baricon.png'; marker = new google.maps.Marker({ position: new google.maps.LatLng(barLocations[i].lat,barLocations[i].lng), map: map, icon: markerImage, title: barLocations[i].company }); } if(barLocations.length > 0) { document.getElementById('divBarLocations').innerHTML = newInnerHTML; } } }); Thanks in advance for any help comments or commentary. Your input is most welcome... The whole code looks more like this: (function() { var map, geocoder, marker, infowindow, barLocations; window.onload = function() { $('#hdivBarLocations').hide(); // Creating a reference to the mapDiv var mapDiv = document.getElementById('map'); // Creating a latLng for the center of the map var latlng = new google.maps.LatLng(37.09, -95.71); // Creating an object literal containing the properties // we want to pass to the map var options = { center: latlng, zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP }; // Creating the map map = new google.maps.Map(mapDiv, options); // Getting a reference to the HTML form var button = document.getElementById('addressButton'); // Catching the forms submit event button.onclick = function() { button.disabled = true; // Getting the address from the text input var address = document.getElementById('addressBox').value; var radius = document.getElementById('radialDistance').value; // Making the Geocoder call getCoordinates(address, radius); // Preventing the form from doing a page submit //return false; $('#hdivBarLocations').show(); } } // Create a function the will return the coordinates for the address function getCoordinates(address, radius) { // Check to see if we already have a geocoded object. If not we create one if(!geocoder) { geocoder = new google.maps.Geocoder(); } // Creating a GeocoderRequest object var geocoderRequest = { address: address } // Making the Geocode request geocoder.geocode(geocoderRequest, function(results, status) { // Check if status is OK before proceeding if (status == google.maps.GeocoderStatus.OK) { //Go back in for some data. document.getElementById('divBarLocations').innerHTML = "No bars found in your area..."; $.ajax({ url: 'ajax.php', data: { lat: results[0].geometry.location.lat(), lng: results[0].geometry.location.lng(), radius: radius }, type: 'post', success: function(output) { barLocations = $.parseJSON(output); //alert(obj[0].lat); /* So now that we have the JSON encoded array it has to be displayed into one of the div's probably below the map someplace */ var newInnerHTML = ""; for(var i = 0; i < barLocations.length; i++) { newInnerHTML = newInnerHTML + "<strong>" + barLocations[i].company + "</strong></br>"; newInnerHTML = newInnerHTML + barLocations[i].first_name + " " + barLocations[i].last_name + "</br>"; newInnerHTML = newInnerHTML + barLocations[i].street_address1 + "</br>" + barLocations[i].street_address2 + "</br>" + barLocations[i].city + "</br>"; newInnerHTML = newInnerHTML + "Phone: " + barLocations[i].phone_number + "</br>"; newInnerHTML = newInnerHTML + "Email: " + barLocations[i].email + "</br>"; newInnerHTML = newInnerHTML + "Website: " + barLocations[i].website + "</br>"; newInnerHTML = newInnerHTML + "<a href=\"standardprofile.php\" target=\"_blank\">Profile page >>>></a>"; newInnerHTML = newInnerHTML + "</br></br>"; } for (i = 0; i < barLocations.length; i++) { var markerImage = 'image/baricon.png'; marker = new google.maps.Marker({ position: new google.maps.LatLng(barLocations[i].lat,barLocations[i].lng), map: map, icon: markerImage, title: barLocations[i].company }); } if(barLocations.length > 0) { document.getElementById('divBarLocations').innerHTML = newInnerHTML; } } }); circ = null; var circ = new google.maps.Circle({ map: map, radius: radius * 1609.344 }); circ.setCenter(results[0].geometry.location); // Center the map on the returned location map.setCenter(results[0].geometry.location); map.fitBounds(circ.getBounds()); google.maps.event.trigger(map,'dragend'); var markerImage = 'image/home.png'; // Check to see if we've already got a Marker object if (!marker) { // Creating a new marker and adding it to the map marker = new google.maps.Marker({ map: map, icon: markerImage }); } // Setting the position of the marker to the returned location marker.setPosition(results[0].geometry.location); // Check to see if we've already got an InfoWindow object if (!infowindow) { // Creating a new InfoWindow infowindow = new google.maps.InfoWindow(); } // Creating the content of the InfoWindow to the address // and the returned position var content = '<span style="color: black;">Your location.</span>'; // Adding the content to the InfoWindow infowindow.setContent(content); // Opening the InfoWindow infowindow.open(map, marker); } }); }})();
×