Search the Community
Showing results for tags 'AJAX'.
-
Hi it me again sorry to ask but I have a huge Problem and need help very fast… I am building a Website for a friend whit both a “mobile” and a “normal” version. I am new to programing any language. So I have almost no experience whit it... I know you normally you would use a CMS like drupal etc. but I don’t like them so… So I knew of the Ajax method using JavaScript so I wanted to use that method to build a simple CMS to swap the content whit “articles” in a folder on the server. So loading a single site is no problem… jQuery - AJAX load() Method or Load page to a div jQuery Mobile So back in the internet I found this method: It changes the div content and adds a #page name to the URL: How to load content with back button enable and refresh using Ajax the script: <!DOCTYPE html> <html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.js"></script> <script type="text/javascript"> $(function(){ // part 1 $('menu a').click(function(){ location.hash=$(this).attr('href').match(/(^.*)\./)[1] return false }) // part 2 var originalTitle=document.title function hashChange(){ var page=location.hash.slice(1) if (page!=""){ $('#content').load(page+".html #sub-content") document.title=originalTitle+' – '+page } } // part 3 if ("onhashchange" in window){ // cool browser $(window).on('hashchange',hashChange).trigger('hashchange') }else{ // lame browser var lastHash='' setInterval(function(){ if (lastHash!=location.hash) hashChange() lastHash=location.hash },100) } }) </script> <title>main</title> </head> <body> <menu> <li><a class="menu_links" href="newproject.html">New Project</a></li> <li><a class="menu_links" href="accord.html">Accordion</a></li> <li><a class="menu_links" href="project_summary.html">Summary Table</a></li> <li><a class="menu_links" href="detail_report.html">Detail Report</a></li> <li><a class="menu_links" href="upload_data.html">Upload Data</a></li> </menu> <div id="content"></div> </body> </html> And in the demo (link) it works well. But for some reason I’m not getting it to work whit my own Site… Could someone please help me by explaining how I have to set all the <div> so that I can build the rest of my site? I know I am asking allot… But please help me… And thanks for reading this Question and answering my questions p.s. sorry for my bad English.
-
This AJAX error is irritating me when every time I try to create a new folder on the folder of the Document Root of my Addon Domain: But after clicking the "OK" button on the alert, the created new folder will appear, I mean, it's created, but still, the error is irritating. But when I try to add a new folder on the folder of the Document Root of my main domain, that error doesn't exist.. Do anybody here experienced the same issue when creating a new folder on the Document Root's folder of an Addon Domain in File Manager? Is there any way to fix it? My details about what's folder of a Document Root that causes the error when I try to add a new folder and about what's my username, are in the attachment. I hope that irritation can be fixed, thanks!
-
Hello There! I am trying to get my chat room, to automatically update the messages and data. As of right now, to see a new message, you must refresh the page. ( I learned from w3schools and don't quite get AJAX as much as I want to. :/ So if I'm way off track, please tell me. ) As always, here is the code I am using: &--#60;?php session_start(); if(!session_is_registered(myusername)){ header("location:/login/main_login.php"); } $myusername = $_SESSION['myusername']; ?&--#62; &--#60;html&--#62; &--#60;head&--#62; &--#60;link rel="SHORTCUT ICON" href="http://oi46.tinypic.com/rky444.jpg"&--#62; &--#60;title&--#62;Mbox:Chat&--#60;/title&--#62; &--#60;script type='text/javascript'&--#62; function updateChat() { var xmlhttp; 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("topscreen").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET",/chat/chatroom.php?error=",true); xmlhttp.send(); } &--#60;/script&--#62; &--#60;style&--#62; /*3DS SCREEN START*/ div#topscreen { border:15px solid; border-color:#1E90FF; overflow:auto; position: absolute; top: 0px; left: 0px; height: 205px; width: 290px; background-color:#FFFFFF; z-index:2; } div#bottomscreen { position: absolute; top: 218px; left: 0px; height: 212px; width: 320px; background-color:#1E90FF; } /*3DS SCREEN STOP*/ div#taskbar { background-color:silver; width:320px; height:100px; position:absolute; top:30px; z-index:5; } &--#60;/style&--#62; &--#60;meta name="viewport" content="width=320"&--#62; &--#60;/head&--#62; &--#60;body&--#62; &--#60;body onload="setInterval('updateChat()',5000);"&--#62; &--#60;!-- TOP SCREEN --&--#62; &--#60;div id="topscreen"&--#62; &--#60;?php $db_sitename="spencer_register"; $db_hostname="localhost"; $db_username="spencer_mega"; $db_password="PASSWORD HERE"; $no_of_comments="15"; /* Leave the script below as it is */ mysql_connect($db_hostname, $db_username, $db_password); mysql_select_db($db_sitename); $pagename=md5($_SERVER['PHP_SELF']); $query=mysql_query("Select * from comments where comment_on='$pagename' ORDER BY id DESC LIMIT 0, $no_of_comments"); while($fetch=mysql_fetch_array($query)) { echo "&--#60;p&--#62;&--#60;b&--#62;&--#60;sub&--#62;".$fetch['comment_by'].": &--#60;/sub&--#62;&--#60;/b&--#62;&--#60;sub&--#62;".$fetch['comment']."&--#60;/sub&--#62;&--#60;/p&--#62;"; } mysql_close(); ?&--#62; &--#60;/div id="topscreen"&--#62; &--#60;!-- BOTTOM SCREEN --&--#62; &--#60;div id="bottomscreen"&--#62; &--#60;!-- PUT STUFF ON THE TASKBAR UNDER THE DIV ID TASKBAR --&--#62; &--#60;div id="taskbar"&--#62; &--#60;a href="../homepage.php"&--#62;&--#60;img src="http://the12.squarespace.com/storage/zzzzhome.png?__SQUARESPACE_CACHEVERSION=1356027845932" width="50px" height="50px"&--#62;&--#60;/a&--#62; &--#60;/div id="taskbar"&--#62; &--#60;!-- Send input box start --&--#62; &--#60;form action="/chat/post_chat.php" method="post"&--#62; &--#60;table&--#62; &--#60;tr&--#62;&--#60;td&--#62; &--#60;/td&--#62;&--#60;td&--#62;&--#60;input type="hidden" name="comment_on" size="" readonly="readonly" value="&--#60;?php print md5($_SERVER['PHP_SELF']); ?&--#62;"/&--#62;&--#60;/td&--#62;&--#60;/tr&--#62; &--#60;input type="hidden" name="comment_by" value="&--#60;?php echo $myusername;?&--#62;"/&--#62; &--#60;tr&--#62;&--#60;td&--#62;&--#60;input name="comment" size="33" maxlength="255" &--#62;&--#60;input type="submit" value="Send!" /&--#62;&--#60;/td&--#62;&--#60;/tr&--#62; &--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62; &--#60;tr&--#62;&--#60;td&--#62;&--#60;/td&--#62;&--#60;td&--#62;&--#60;/td&--#62;&--#60;/tr&--#62; &--#60;/table&--#62; &--#60;/form&--#62; &--#60;/div id="bottomscreen"&--#62; &--#60;/body&--#62; &--#60;/html&--#62; Yeah I know. =P Some messy coding, but I'm working on it. Alright, well thanks in advance! ~ Spencer