aureolin Posted January 29, 2008 Share Posted January 29, 2008 I'm submitting an AJAX request to my server (I'm running a WAMP stack). I can see the server process the request in XDebug and set the return string (an HTML <form>...</form>) correctly. Here's the kicker - when I look at the the responseText from the Ajax request in Firebug, it's not the data that was sent, it's a copy of the entire web page! At the moment I'm stumped. For one, this AJAX request is kicked off as the result of a previously successful AJAX request (a login), but that one works perfectly?? Any idea where to look? Steve G. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted January 29, 2008 Share Posted January 29, 2008 Post your code, so I can take a better look at it. Quote Link to comment Share on other sites More sharing options...
priti Posted January 29, 2008 Share Posted January 29, 2008 I'm submitting an AJAX request to my server (I'm running a WAMP stack). I can see the server process the request in XDebug and set the return string (an HTML <form>...</form>) correctly. Here's the kicker - when I look at the the responseText from the Ajax request in Firebug, it's not the data that was sent, it's a copy of the entire web page! At the moment I'm stumped. For one, this AJAX request is kicked off as the result of a previously successful AJAX request (a login), but that one works perfectly?? Any idea where to look? Steve G. Are you using some template like smarty??? Quote Link to comment Share on other sites More sharing options...
aureolin Posted January 30, 2008 Author Share Posted January 30, 2008 Found the answer, and in a surprising place. First, to recap: The problem is that an AJAX call is returning not the form I requested, but the entire web page. Some details on the situation: I'm using a WAMP stack; WinXP, Apache 2.2, PHP 5.2 (i.e. latest stable builds). I'm not using any templates (eg. Smarty); this is just your basic AJAX call. I've tried using the Prototype and jx libraries as well as hand written XMLHttpRequest object code. The problem happens in both Firefox and IE. I can walk through the server code w/ XDEBUG and see the AJAX response being generated correctly. I can walk through the client code and see that the XMLHttpRequest.responseText is the full web page, not the <form> ... </form> fragment that I saw being generated in XDEBUG. After I poked around some, I did find the problem. Here's the offending bit of code... Rq=getXMLHttpObj(); Rq.open('get', 'RequestForm.php?form=someform', true); // this line has the error Rq.send(null); Do you see the problem? The answer was in the Apache access.log file. When I looked there I saw that the page that Apache was processing for this request was "parentpage.php/RequestForm.php?form=someform". When I changed the "open" call as follows, everything started working properly... Rq.open('get', '/RequestForm.php?form=someform', true); // this line is correct Yes, that's right. Just adding a '/' to the start of the requested URL fixed the problem. At the moment, I'm calling this an Apache oddity. I'm reluctant to call this a bug - maybe it's supposed to work this way?? Anyway, I hope this helps someone else!! Steve G. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.