473,396 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with XMLHttpRequest

Hi

I'm having a bit starting problem with java ajax.

I have this rather simple script
Expand|Select|Wrap|Line Numbers
  1. function UpdateSQL(ReleaseID, MediaTypeID, sideElement) {
  2.     if (typeof XMLHttpRequest != 'undefined') {
  3.         return new XMLHttpRequest();
  4.     }
  5.     try {
  6.         return new ActiveXObject("Msxml2.XMLHTTP");
  7.     } catch (e) {
  8.         try {
  9.             return new ActiveXObject("Microsoft.XMLHTTP");
  10.         } catch (e) {}
  11.     }
  12.     return false; 
  13.  
  14.      req.onreadystatechange = function() {answerUpdateSQL(sideElement);};
  15.      req.open("GET", "Submit2-addmedia.php" + "?ReleaseID=" + ReleaseID + "&MediaTypeID=" + MediaTypeID", true);
  16.      req.send(null);
  17. }
  18.  
  19.  
  20. function answerUpdateSQL(sideElement) {
  21.    var output = '';
  22.    if(req.readyState == 4) {
  23.       if(req.status == 200) {
  24.          output = req.responseText;
  25.          document.getElementById(sideElement).innerHTML = output;
  26.          }
  27.       }
  28.   }
And on the page I write
[HTML]<img src="Graphics/Tree/cd.gif" onClick="UpdateSQL('1','4,'show');">
<div id="show"></div>[/HTML]


This should get the Submit2-addmedia.php file with the extensions ReleaseID = 1 and MediaTypeID = 4 but it just doesn't work.

Nothing happens when I click the image.

I have tried removing the extensions so the script is just
req.open("GET", "Submit2-addmedia.php", true);
and in the file just write "Test"
But Test is not written in the show div.


So something is wrong so it doesn't get the fle probably.
But I'm new at this, and I just can't figure it out ?


So can anyone tell me what I'm doing wrong.
It's probably a simple little thing I'm missing ??


Best
Michael
Feb 18 '08 #1
2 1093
BigDaddyLH
1,216 Expert 1GB
Moving from Java to JavaScript forum, since Java is not JavaScript.
Feb 18 '08 #2
acoder
16,027 Expert Mod 8TB
UpdateSQL('1','4,'show'); should be UpdateSQL('1','4','show'); Note the missing end single quote.
Feb 18 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dominic Myers | last post by:
Hi there, I'm playing with XMLHttpRequest and followed the article by Bill Bercik at http://www.webpasties.com/xmlHttpRequest/... I'm having problems getting the last two steps to work though....
4
by: David Wang | last post by:
Ive been playing around with xmlHTTPRequest and was wondering if i was programming a part of my code wrong. what i want to do is have the browser access another part of my site using...
42
by: Greg | last post by:
Hi, I've designed a bookmark in Ajax / PHP that I will put soon on sourceforge.net. But I've got an very tricky bug. I try it on some computers with Internet Explorer/Windows, Firefox...
7
by: KaNos | last post by:
Hello aspx world, I consume a webservice with Javascript functions. But the response is ok and, very strange, document is null. How to resolve this problem thanks ?????? ...
3
by: Simon | last post by:
I have the following code in Javascript which is creating and sending an XMLHttpRequest . <code> var xmlHttp; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlHttp = new...
1
by: ScriptProblem | last post by:
Hi Guys, I have a security concern with Mozilla and Netscape browsers(In IE it gives secuirity pop window) in Remote server(Client's server).When I am trying to call an Asp.NET web service from...
1
by: Charlie | last post by:
I am trying to make an XMLHttpRequest which violates the default "same- origin"policy in Firefox. I checked the archives and found a method that should work but it does not. Below is the test code...
1
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest...
8
dmjpro
by: dmjpro | last post by:
i m generating a xml file through jsp file using AJAX. my response header in jsp file is like this .. <%@ page contentType = "text/xml;charset = WINDOWS-1252"%> when i do...
8
by: Samik R. | last post by:
Hello, I am using the innerHTML property of a div placeholder to update the contents, and the HTML is provided from a perl script on the server side. The perl script gets called through AJAX when I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.