Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
Thread: im=nput using xmlHttp
06-27-2013, 05:32 AM #1
- Join Date
- Jun 2013
- Thanked 0 Times in 0 Posts
im=nput using xmlHttp
I am a web novice and I have a site I inherited. One page is an online chart displaying volunteer names. People can input their name, edit or delete them. For some reason the input is not working. Nothing changed on the page. The problem is when editing the names on the page there is a popup error stating "failed to save" What is my next move here, I am struggling to understand this java function and why it's not working. Here is some of the script. I don't really understand it, but I know this is controlling the input:
Last edited by VIPStephan; 06-27-2013 at 08:28 AM. Reason: added code BB tags
06-27-2013, 07:48 AM #2
- Join Date
- Nov 2010
- Thanked 248 Times in 248 Posts
alert('failed to save');
alert('failed to save. Response text : '+id);
06-27-2013, 07:58 AM #3
- Join Date
- Nov 2010
- Thanked 32 Times in 31 Posts
I am not a js or ajax expert but you wanted to know what this was, its ajax. Basically what ajax does is allows you to set up another page process many times its a php page with output to the user, in your case its a file called ajax.php and this process grabs that output and uses it on this page.
For example you have a php file called sample.php and all it does is display the text hello back to the user. Well what you can do is you can in simple terms listen for that output by telling ajax in this file that you want to grab the output from that sample.php file when it is done executing.
The stateChanged is what ajax watches for, when that is status 4 or completed (i think status 2 works as well) then the http object basically is the word "hello" and ajax sees by the status that the file is done executing and so it grabs the value of that "hello" text using the function saveName.
As far as all the other stuff the document.getElementById its grabbing the value from that id value and basically your building a final value with this process. Grabbing some data here some there.
So i hope that basically explains whats going on, im not an expert so i cant tell you why exactly its not working and i dont know what you mean by not working, are you getting an error or is there no output or what. But if you explain what you need that is not happening or maybe even give a screen shot somone can prob help you. But also they can prob just look at the code and see if they see any errors.
Hope that helps.
How did i do DanInMa?
Last edited by durangod; 06-27-2013 at 08:21 AM.
06-28-2013, 10:35 PM #4
I don't think DanInMa's change will help find the problem.
True, it will show that what is coming back from the AJAX call is not a number greater than zero, but the real root of the problem is almost surely in the PHP code that is sending back that bad number.
I think the more important thing is to find out what the URL is that is being used when the error occurs.
So to that end, I'd add a debug line here:
url=url+"?id="+id; alert("Calling AJAX with url: " + url);An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.