Simple ajax not working.


,
I am working on a small assigment but this code just wont work. I dont know what the problem is.
Can anyone please debug it. var xmlhttp; function listFriend(){ xmlhttp = false; /* For Firefox*/ if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else /*For IE*/ if (window.ActiveXObject) { try { /*For some versions of IE*/ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { /*For some other versions of IE*/ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!xmlhttp) { alert('Cannot create XMLHTTP instance'); return false; } var delfrnd = document.forms[0].elements["delFriends"].value; var url = "editFriends_ajaxing.phpdelFriends="+delfrnd; alert(delfrnd+" "+url); xmlhttp.open('GET', url, true); xmlhttp.onreadystatechange = theResponse; xmlhttp.send(null); } //End showUserName function theResponse(){ alert("entering the function theResponse,readystate= "+xmlhttp.readyState+"status="+xmlhttp.status); if(xmlhttp.readyState==4) { if(xmlhttp.status==200) { alert("inside the iffs"); var xmlDoctext=xmlhttp.responseText; alert("xmlDoctxt is \n"+xmlDoctext); var xmlDoc=xmlhttp.responseXML.documentElement; var rootElement=xmlDoc.documentElement; alert("xmldoc = "+xmlDoc); var htmlArray=[];//An array in which to accumulate HTML fragments in lieu of String += "....". htmlArray.push("Friend NameSelect to Delete"); var length=xmlDoc.childNodes.length; alert("htmlArray is \n"+htmlArray); for(var i=0; i
Posted On: Saturday 24th of November 2012 04:09:10 AM Total Views:  204
View Complete with Replies

RELATED TOPICS OF JavaScript PROGRAMMING LANGUAGE




simple ajax script problem

HI, Im new here so hello all! Im having this problem with a v simle ajax script. Heres the code: test page var request = null; function createRequest() { try { request = new XMLHttpRequest(); } catch (trymicrosoft) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { request = null; } } } if (request == null) alert("Error creating request object!"); } function get_message() { var message_id = document.getElementById("message_id").value; createRequest(); var url = "edit_message.phpmessage_id=" + escape(message_id); request.open("GET", url, true); request.onreadystatechange = open_message; request.send(null); } function open_message() { if(request.readystate == 4) { var message_txt = request.responseText; var message_area = document.getElementById("message_text"); replaceText(message_area, message_txt); } }
VIEWS ON THIS POST

114

Posted on:

Monday 19th November 2012
View Replies!

Is there a simpler way to do this?

I need to mimic what is going on in this sample with just javascript. This will only be used for mobile so I don't want to have to load the jQuery library and slow the user down. Can anyone suggest a simpler way to go about this http://jsfiddle.net/Q2bzT/
VIEWS ON THIS POST

126

Posted on:

Monday 19th November 2012
View Replies!

Super simple script, doc write not rendering

I'm in my first Javascript class. I've been staring at this assignment for about an hour, trying to figure out why my document.write() lines won't render in my browser. The prompt boxes come up just fine, and everything else in the body tags shows up. I know I'm missing something simple. I've been through my textbook, the prefessor's powerpoints, and a few online references, and it looks like i have my syntax correct. What am I missing Thank you! Chapter 3 Assignment 2 var first_name = prompt("What is your first name",""); var last_name = prompt("What is your last name",""); var hourly_wage = prompt("What is your hourly wage",""); hourly_wage = parseFloat(hourly_wage) var weekly_pay = hourly_wage*40; var job_id; var job_title; job_id = "B0123456"; job_title = "Programmer"; document.write("First Name: " + first_name); document.write("Last Name: " + last_name); document.write("Job Title: " + job_title); document.write("Job ID:< "/b> + job_id); document.write("Weekly Pay: $" + weekly_pay); Trident Technical College THE END Just noticed this: document.write("Job ID:< "/b> + job_id);
VIEWS ON THIS POST

93

Posted on:

Monday 19th November 2012
View Replies!

trying to learn ajax, simple chat program

im working on a simple chat program and this is whats on the page function callAjax() { var xmlhttp; if (str.length==0) { 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","refreshchat.php,true); xmlhttp.send(); } function refreshchat() { var x = document.getElementById("textarea1"); x.innerHTML = callAjax(); } and on a page called refreshchat.php i have im confussed on whats wrong
VIEWS ON THIS POST

143

Posted on:

Wednesday 21st November 2012
View Replies!

simple question

It's seriously been six years since i did anything at all in javascript. explain to me what i'm doing wrong (it doesn't print into the code): (i need to output the following : [[image:header1]]
VIEWS ON THIS POST

144

Posted on:

Wednesday 21st November 2012
View Replies!

Creating a simple search box

I am currently making a simple search box that uses the Google search engine for my website. I know I could use the Custom Search engine but I wanted to do it myself. Basically, it all works; you type something in and press the button and it searches google for it. What I wanted to know was how to do this but by pressing enter instead. Here is my code: HTML Javascript function google() { var str = document.forms.f.input.value; var url = "http://www.google.co.uk/#hl=en&q=" + str + "&meta=&fp=7b0c7eda66a2283c"; window.location = url; }
VIEWS ON THIS POST

106

Posted on:

Wednesday 21st November 2012
View Replies!

simple email validation

hi there, have these simple code for email validation but I am stuck as I want to predefine gmail emails to give ex discount... here is the code: Check Email Address function checkEmail(inputvalue){ var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/; if(pattern.test(inputvalue)){ alert("true"); }else{ alert("false"); } } Input your email: but when i change that code to recognize gmail function checkEmail(inputvalue){ var pattern=/^([a-zA-Z0-9_.-])+@(gmail])+\.([a-zA-Z])+([a-zA-Z])+/; if(pattern.test(inputvalue)){ alert("true"); }else{ alert("false"); } } only gmail accounts are valid any chance to implement @(gmail]) & @([a-zA-Z0-9_.-])
VIEWS ON THIS POST

86

Posted on:

Wednesday 21st November 2012
View Replies!

simple if/else-if not working

I am trying to basically make a toggle button on the first button click i need it to move down on the second button click move back up to the original position. I am simply just trying to make the button have a state by changing the class. So first click it removes the up class and adds the down class. On the second click it removes the down class and adds the up class. for some reason the it removes the up class and adds the down but it will not do the opposite testing document $(document).ready(function() { $("button").click(function(){ if($("button").hasClass("up")) { $("button").removeClass("up") $("button").addClass("down") } else if($("button").hasClass("up")) { $("button").removeClass("down") $("button").addClass("up") }; }); }); Show all p elements
VIEWS ON THIS POST

88

Posted on:

Wednesday 21st November 2012
View Replies!

I need a simple date format for JavaScript code.

I need help with the date format of some javascript code I'm using. Here's the code: // function to add number of days (accepts number of days to add) function AddDays(days) { var thisDate = new Date(); thisDate.setDate(thisDate.getDate() + days); return thisDate; } document.write(AddDays(366)) This is what I get: Thu Aug 09 2012 16:45:34 GMT-0500 (CDT) I just want: Aug 09 2012
VIEWS ON THIS POST

100

Posted on:

Wednesday 21st November 2012
View Replies!

How can I implement a simple virtual keyboard ?

Hi How can I implement a simple virtual keyboard for a website... the only things I need is a number pad(0 -9)... I hope there is a way to implement it as simple as possible using the Javascript...
VIEWS ON THIS POST

113

Posted on:

Wednesday 21st November 2012
View Replies!

simple payroll

@
VIEWS ON THIS POST

200

Posted on:

Wednesday 21st November 2012
View Replies!

simple problem

I just entered a javascript class and the teacher wanted us to display text onto an HTML file using a external Javascript page. I tried setting up var in the external var greeting = ' world'; then in the html file I tried the document.write function document.write(greeting); I put the right script type"text/javascript" src=lab2.js and then end it I have no idea why it isn't working, and yes I am a newb at this stuff and been reading the book, java script: the Missing Manual
VIEWS ON THIS POST

85

Posted on:

Wednesday 21st November 2012
View Replies!

Why does this simple AJAX text changer not work?

I am just starting to do some AJAX after learning various other web programming languages and I can't get this to work. When I click the button, it doesn't do anything. Here's my code. function onclick() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","ajaxtest.txt",true); xmlhttp.send(); } Let AJAX Chage this text Request AJAX Server transfer I would really appreciate help! Here is the link if you want to test it.
VIEWS ON THIS POST

99

Posted on:

Thursday 22nd November 2012
View Replies!

simple javascript?

My problem is this: print the sum of 2+2 and display the result in an alert window in the browser. function Demo(){ var nsum = $(2+2=4); alert(nsum.size()); } How do I tell the query to solve the problem. I am very new to javascript so don't criticize too bad I am
VIEWS ON THIS POST

56

Posted on:

Thursday 22nd November 2012
View Replies!

simplest way to make hidden divs visible via onlick and javascript?

can someone please show me how to do this i dont know javascript, and I can't understand the code samples i see online. what is the easiest way (least amount of code) to make an tag make a div visible
VIEWS ON THIS POST

67

Posted on:

Friday 23rd November 2012
View Replies!

Very simple thing isn't working

i'm new to javascript and I'm just wondering why this isnt displaying the alert messages.. can anyone shed some light $(document).ready(function() { $("#username").keyup(function(e) { var usr = $("#username").val(); var allready= 0; if(usr.length > 3) { allready= 1; $('input[type="submit"]').removeAttr('disabled'); } else $('input[type="submit"]').attr('disabled', true); allready = 0; }) function checkdone() { if (allready == 1) { $('input[type="submit"]').removeAttr('disabled'); alert(' ready is true'); } else alert(' ready is false'); $('input[type="submit"]').attr('disabled', true); } window.setInterval(checkdone(), 1000); });
VIEWS ON THIS POST

101

Posted on:

Saturday 24th November 2012
View Replies!

I'm trying to setup a simple color picker for text?

Sorry this is so long but I don't know how else to show and explain it. I tried setting this up on a free webs.com account but it doesn;t allow forms so doesn't work. I run an Apache server for my family's web site. One of the things it does is allow us to share messages. What I want to do is allow family members to add color to the text messages they are entering. I had no problem getting things like Bold, Italic, Underline to works as they are all handled within the page. In trying to add color, I've downloaded a few different color pickers. The one I am currently trying is js_color_picker_v2 which does everything I need except I can't figure out how to get the #rrggbb selected value back to the page the message is entered in and where the selected text to be colored is. I can get it back to a type=hidden variable but don't see how I then kick the page again to process the data the popup window placed there. Part of my problem is I think serially and the popup window generated by Javascript is not modal so the javascript code in the page that invokes the color popup generator completes without any response from the popup window. Basically I'm trying to implement the Colors (A) option that is available here (between Remove Text Formatting and Smiles). If someone can describe how that's done that would give me a good place to start. I've written a lot of html/javascript/css to support the family web site. I'm usually able to figure out how to do things but am very frustrated with this one so any help would be greatly appreciated. This is what it looks like when I run it: As you can see (hopefully) the insert of the font tags occurs before I get a chance to select a color from the color picker. Here is the code: // --------------------------------------------------------------------------- // Choose a color then apply to the selected area text of the inut area. // --------------------------------------------------------------------------- function pickColor($obj1) { showColorPicker($obj1,document.forms[0].rgb2) $color=document.forms[0].rgb2.value //alert($color) var $tb = document.getElementById("textinput"); if (document.selection) { var str=document.selection.createRange().text; if (str != '' && str!= 'undefined') { var sel=document.selection.createRange(); sel.text=""+str+""; } } else if (typeof $tb.selectionStart != 'undefined') { var $before, $after, $selection; if ($tb.selectionStart == 0) // Starts at left edge $before = ''; // No before then else $before= $tb.value.substring(0, $tb.selectionStart); $selection = $tb.value.substring($tb.selectionStart, $tb.selectionEnd); if ($selection != "") { if ($tb.selectionEnd == $tb.value.length) // Ends at left edge $after = ''; // No after then else $after = $tb.value.substring($tb.selectionEnd, $tb.value.length); $tb.value= String.concat($before, "",$selection,"",$after); } } $tb.focus(); return false; } This is some text in a textarea input box. Click here to select Color: Use the mouse to select some of the text then click the A above. What I want to happen is that when you chose a color the appropriate <font color=#rrggbb> and </font> will be wrapped around the selected text.
VIEWS ON THIS POST

255

Posted on:

Saturday 24th November 2012
View Replies!

simple javascript not working

I don't know javascript very well... I have a form with the name register_group and a radio button for pc_parade_float with yes/no options. I want to display a different comment depending on if they clicked yes or no in the radio button. The code I have is as follows: if(document.register_group.pc_parade_float[0].checked==true) {document.writeln('use PayPal to pay your $75.00 registration fee.')} else {document.writeln('use PayPal to pay your $50.00 registration fee.')} Note that this code is outside the if that matters. If I change the value of the button it does not change the value of the output. What am I missing. Do I need an on-click event in the of the buttons to trigger the change If so what would it be
VIEWS ON THIS POST

60

Posted on:

Saturday 24th November 2012
View Replies!

ajax simple request response problem

I'm new to AJAX and i'm trying to make my first AJAX request response program work. My code works fine in Mozilla Firefox. However, it is not working in IE9. The following is the result i'm getting in IE9: today is July 11, 2011, 10:55 am Notice: Use of undefined constant fname - assumed 'fname' in C:\wamp\www\Ajax\demo_get.php on line 4 Notice: Use of undefined constant lname - assumed 'lname' in C:\wamp\www\Ajax\demo_get.php on line 4 hello fnameand lname! does anyone know on what i'm doing wrong the following is my code: request.html function loadXMLDoc() {var xmlhttp; if (window.XMLHttpRequest) //checks if browser supports XMLHttpRequest object {//code for IE7, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {//code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } //when async=true, the function in onreadystatechange event executes when the response is ready xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET", "demo_get.phpfname=Henry&lname=Ford",true); xmlhttp.send(); } REquest Data demo_get.php
VIEWS ON THIS POST

93

Posted on:

Saturday 24th November 2012
View Replies!

Need Help on simple CSS problem

Hai all, I need help on a simple CSS problem. I'm using the clicktohide and clicktoshow for my fmbl page but it seems that the first page is not showing. The site is here http://www.facebook.com/pages/EZ-Fanpage-Mini-Site-Sample-1/162645693772019v=app_7146470109 Can anyone help me I wanted to post the code here but the code is very very very long. Let me know than i will pmp you the code. Cheers and
VIEWS ON THIS POST

66

Posted on:

Saturday 24th November 2012
View Replies!