473,405 Members | 2,282 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,405 software developers and data experts.

xmlHTTP Request returns 403 in FireFox when Post used

Currently transitioning from a shared host to a dedicated server. The
same code that works on the old server is not working on the dedicated
server. It is a simple AJAX request like:

<code>
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function doRequestUsingPOST() {
createXMLHttpRequest();
var queryString = "response.php?";
queryString = queryString + createQueryString() ;
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("POST", queryString, true);
xmlHttp.send(null);
}
</code>

With the code as is above, the requests works fine in IE. With Firefox
it throws a 403 on the page. A call to the response.php page with
parameters runs correctly outside of AJAX. Changing all POST requests
to GET resolves the issue, but I would prefer not to have to change
ALL POST requests to GET requests.

Does anyone know of a setting on the new server that can cause FireFox
(1.5.x and 2.0.x) to return a 403 with an AJAX post call?

Mar 30 '07 #1
14 9964
FMDeveloper wrote:
Does anyone know of a setting on the new server that can cause FireFox
(1.5.x and 2.0.x) to return a 403 with an AJAX post call?
The server sends that HTTP response status code. Check whether
responseText contains details why the request is forbidden.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 31 '07 #2
On Mar 31, 4:39 am, Martin Honnen <mahotr...@yahoo.dewrote:
FMDeveloper wrote:
Does anyone know of a setting on the new server that can cause FireFox
(1.5.x and 2.0.x) to return a 403 with an AJAX post call?

The server sends that HTTP response status code. Check whether
responseText contains details why the request is forbidden.

--

Martin Honnen
http://JavaScript.FAQTs.com/
The responseText only contains the 403 error message from the server

Apr 2 '07 #3
FMDeveloper wrote:
On Mar 31, 4:39 am, Martin Honnen <mahotr...@yahoo.dewrote:
>>FMDeveloper wrote:
>>>Does anyone know of a setting on the new server that can cause FireFox
(1.5.x and 2.0.x) to return a 403 with an AJAX post call?

The server sends that HTTP response status code. Check whether
responseText contains details why the request is forbidden.

The responseText only contains the 403 error message from the server
Then check the server's error log.

--
Ian Collins.
Apr 2 '07 #4
FMDeveloper wrote:
Currently transitioning from a shared host to a dedicated server. The
same code that works on the old server is not working on the dedicated
server. It is a simple AJAX request like:

<code>
function createXMLHttpRequest() {
if (window.ActiveXObject) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest) {
xmlHttp = new XMLHttpRequest();
}
}
function doRequestUsingPOST() {
createXMLHttpRequest();
var queryString = "response.php?";
queryString = queryString + createQueryString() ;
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("POST", queryString, true);
xmlHttp.send(null);
}
</code>

With the code as is above, the requests works fine in IE. With Firefox
it throws a 403 on the page. A call to the response.php page with
parameters runs correctly outside of AJAX. Changing all POST requests
to GET resolves the issue, but I would prefer not to have to change
ALL POST requests to GET requests.

Does anyone know of a setting on the new server that can cause FireFox
(1.5.x and 2.0.x) to return a 403 with an AJAX post call?
Pretty sure you're getting that error because you didn't set the ajax
header to indicate you were sending data as a post. After your
xmlHttp.open place the following line...

xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");

If you're not sending anything -- and since you have send(null) you're
not sending any data -- (because posts are sent via xmlHttp.send(data))
then you don't need to use post and get would work quite nicely.
Apr 2 '07 #5
pcx99 wrote:
FMDeveloper wrote:
>>
Does anyone know of a setting on the new server that can cause FireFox
(1.5.x and 2.0.x) to return a 403 with an AJAX post call?

Pretty sure you're getting that error because you didn't set the ajax
header to indicate you were sending data as a post. After your
xmlHttp.open place the following line...

xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");

If you're not sending anything -- and since you have send(null) you're
not sending any data -- (because posts are sent via xmlHttp.send(data))
then you don't need to use post and get would work quite nicely.
I'm sure you only have to set the Content-type on post requests if there
is data being sent.

--
Ian Collins.
Apr 2 '07 #6
On Apr 2, 2:52 pm, Ian Collins <ian-n...@hotmail.comwrote:
FMDeveloper wrote:
On Mar 31, 4:39 am, Martin Honnen <mahotr...@yahoo.dewrote:
>FMDeveloper wrote:
>>Does anyone know of a setting on the new server that can cause FireFox
(1.5.x and 2.0.x) to return a 403 with an AJAX post call?
>The server sends that HTTP response status code. Check whether
responseText contains details why the request is forbidden.
The responseText only contains the 403 error message from the server

Then check the server's error log.

--
Ian Collins.
No further hint in the log that I can see. The relevant part is below:

63.202.xxx.xxx - - [02/Apr/2007:16:10:33 -0700] "GET /includes/
styles.css HTTP/1.1" 200 3437 "http://host.com/adjustment.php"
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/
20070309 Firefox/2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:34 -0700] "GET /adjustment.php
HTTP/1.1" 200 78514 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-
US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:35 -0700] "GET /favicon.ico HTTP/
1.1" 200 1150 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:37 -0700] "GET /finder.php?row=1
HTTP/1.1" 200 3984 "http://host.com/adjustment.php" "Mozilla/5.0
(Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/
2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:37 -0700] "GET /includes/
style.css HTTP/1.1" 200 1027 "http://host.com/finder.php?row=1"
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/
20070309 Firefox/2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:39 -0700] "GET /response.php?
brand=19&ts=1175555465215 HTTP/1.1" 200 1757 "http://host.com/
finder.php?row=1" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:40 -0700] "POST /listing.php?
brand=19&size=11L-16&ts=1175555466434 HTTP/1.1" 403 652 "http://
host.com/finder.php?row=1" "Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3"

I changed the first AJAX call to a get and it works. The same type of
call as a post fails.

Apr 2 '07 #7
On Apr 2, 4:15 pm, "FMDeveloper" <fmdeveloper...@gmail.comwrote:
On Apr 2, 2:52 pm, Ian Collins <ian-n...@hotmail.comwrote:
FMDeveloper wrote:
On Mar 31, 4:39 am, Martin Honnen <mahotr...@yahoo.dewrote:
>>FMDeveloper wrote:
>>>Does anyone know of a setting on the new server that can causeFireFox
>>>(1.5.x and 2.0.x) to return a 403 with anAJAXpostcall?
>>The server sends that HTTP response status code. Check whether
>>responseText contains details why the request is forbidden.
The responseTextonlycontains the 403 error message from the server
Then check the server's error log.
--
Ian Collins.

No further hint in the log that I can see. The relevant part is below:

63.202.xxx.xxx - - [02/Apr/2007:16:10:33 -0700] "GET/includes/
styles.css HTTP/1.1" 200 3437 "http://host.com/adjustment.php"
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/
20070309Firefox/2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:34 -0700] "GET/adjustment.php
HTTP/1.1" 200 78514 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-
US; rv:1.8.1.3) Gecko/20070309Firefox/2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:35 -0700] "GET/favicon.ico HTTP/
1.1" 200 1150 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.8.1.3) Gecko/20070309Firefox/2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:37 -0700] "GET/finder.php?row=1
HTTP/1.1" 200 3984 "http://host.com/adjustment.php" "Mozilla/5.0
(Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309Firefox/
2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:37 -0700] "GET/includes/
style.css HTTP/1.1" 200 1027 "http://host.com/finder.php?row=1"
"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/
20070309Firefox/2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:39 -0700] "GET/response.php?
brand=19&ts=1175555465215 HTTP/1.1" 200 1757 "http://host.com/
finder.php?row=1" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.8.1.3) Gecko/20070309Firefox/2.0.0.3"
63.202.xxx.xxx - - [02/Apr/2007:16:10:40 -0700] "POST/listing.php?
brand=19&size=11L-16&ts=1175555466434 HTTP/1.1" 403 652 "http://
host.com/finder.php?row=1" "Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv:1.8.1.3) Gecko/20070309Firefox/2.0.0.3"

I changed the firstAJAXcall to agetand itworks. The same type of
call as apostfails.
Adding xmlHttp.setRequestHeader("Content-type","application/x-www-form-
urlencoded"); did not solve the issue.

An example url that would be placed into queryString in
xmlHttp.open("Post", queryString, true) is
http://www.host.com/listing.php?bran...=1175560027602

Apr 3 '07 #8
Ian Collins wrote:
pcx99 wrote:
>FMDeveloper wrote:
>>Does anyone know of a setting on the new server that can cause FireFox
(1.5.x and 2.0.x) to return a 403 with an AJAX post call?
Pretty sure you're getting that error because you didn't set the ajax
header to indicate you were sending data as a post. After your
xmlHttp.open place the following line...

xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");

If you're not sending anything -- and since you have send(null) you're
not sending any data -- (because posts are sent via xmlHttp.send(data))
then you don't need to use post and get would work quite nicely.

I'm sure you only have to set the Content-type on post requests if there
is data being sent.

Ah well, it was worth a guess.

Hmm 403. If it was 405 then it would be because he was trying to post
to a static file (not php or server-side program). With 403 he may be
running into apache's mod_security which tries to filter out some hack
attempts.

I'd disable mod_security for a few mins and try to post with it
disabled. I know a few of my articles which deal with htaccess I need
to disable mod_security to upload them through the browser and if I
forget I get a 403 error.

You can disable the code by editing .htaccess and adding the following
lines (assuming your web-host allows this).

<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

After you're done either remove the lines or insert a # in front of each
line to comment it out.
Apr 3 '07 #9
pcx99 wrote:
Ian Collins wrote:
>pcx99 wrote:
>>FMDeveloper wrote:
Does anyone know of a setting on the new server that can cause FireFox
(1.5.x and 2.0.x) to return a 403 with an AJAX post call?

Pretty sure you're getting that error because you didn't set the ajax
header to indicate you were sending data as a post. After your
xmlHttp.open place the following line...

xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
If you're not sending anything -- and since you have send(null) you're
not sending any data -- (because posts are sent via xmlHttp.send(data))
then you don't need to use post and get would work quite nicely.

I'm sure you only have to set the Content-type on post requests if there
is data being sent.


Ah well, it was worth a guess.

Hmm 403. If it was 405 then it would be because he was trying to post
to a static file (not php or server-side program). With 403 he may be
running into apache's mod_security which tries to filter out some hack
attempts.

I'd disable mod_security for a few mins and try to post with it
disabled. I know a few of my articles which deal with htaccess I need
to disable mod_security to upload them through the browser and if I
forget I get a 403 error.

You can disable the code by editing .htaccess and adding the following
lines (assuming your web-host allows this).

<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>

After you're done either remove the lines or insert a # in front of each
line to comment it out.
And it works in IE so it's unlikely to be an .htaccess problem.
Frustrating problem. In another post he said adding the header didn't
fix the problem. I'd still try the .htaccess change because its quick
and easy to check (assuming he's running apache), but other than that
I'm stumped (<<< usual condition).

Apr 3 '07 #10
pcx99 wrote:
Ian Collins wrote:
>pcx99 wrote:
>>>
If you're not sending anything -- and since you have send(null) you're
not sending any data -- (because posts are sent via xmlHttp.send(data))
then you don't need to use post and get would work quite nicely.


I'm sure you only have to set the Content-type on post requests if there
is data being sent.

Ah well, it was worth a guess.

Hmm 403. If it was 405 then it would be because he was trying to post
to a static file (not php or server-side program). With 403 he may be
running into apache's mod_security which tries to filter out some hack
attempts.
He doesn't say which server he is using and the log didn't look like an
Apache error log.
I'd disable mod_security for a few mins and try to post with it
disabled. I know a few of my articles which deal with htaccess I need
to disable mod_security to upload them through the browser and if I
forget I get a 403 error.
It's odd, because I use these style of requests all the time and haven't
hit this error.

--
Ian Collins.
Apr 3 '07 #11
FMDeveloper wrote:
>
Adding xmlHttp.setRequestHeader("Content-type","application/x-www-form-
urlencoded"); did not solve the issue.

An example url that would be placed into queryString in
xmlHttp.open("Post", queryString, true) is
http://www.host.com/listing.php?bran...=1175560027602
All I can suggest is you look at the request packets on the wire and
compare the headers sent by each browser.

--
Ian Collins.
Apr 3 '07 #12
On Apr 2, 6:39 pm, Ian Collins <ian-n...@hotmail.comwrote:
FMDeveloper wrote:
Adding xmlHttp.setRequestHeader("Content-type","application/x-www-form-
urlencoded"); did not solve the issue.
An example url that would be placed into queryString in
xmlHttp.open("Post", queryString, true) is
http://www.host.com/listing.php?bran...=1175560027602

All I can suggest is you look at the request packets on the wire and
compare the headers sent by each browser.

--
Ian Collins.
Running Apache 1.3.37 - mod_security is disabled, so I will test that
now

Apr 3 '07 #13
On Apr 3, 11:50 am, "FMDeveloper" <fmdeveloper...@gmail.comwrote:
On Apr 2, 6:39 pm, Ian Collins <ian-n...@hotmail.comwrote:
FMDeveloper wrote:
Adding xmlHttp.setRequestHeader("Content-type","application/x-www-form-
urlencoded"); did not solve the issue.
An example url that would be placed into queryString in
xmlHttp.open("Post", queryString, true) is
>http://www.host.com/listing.php?bran...=1175560027602
All I can suggest is you look at the request packets on the wire and
compare the headers sent by each browser.
--
Ian Collins.

Running Apache 1.3.37 - mod_security is disabled, so I will test that
now
THANKS FOR ALL YOUR HELP GUYS! It does appear that mod_security on
Apache 1.3.37 will cause FireFox to return a 403 with the code sample
I provided. Disabling mod_security allows all of the posts to work.

Apr 4 '07 #14
Hey,

The guys above pointed a lot of stuff out. However since you are doing
a POST with ajax your xmlHttp.send should be the post parameters not a
null value. Even though you've specified a post your request is sent
like a get..

A proper post would be as below..

function doRequestUsingPOST() {
createXMLHttpRequest();
var postURL = "response.php";

xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.open("POST", postURL, true);

//createQueryString returns something like
//name=<name>&address=<address>&variable3=<variable3 etc etc
xmlHttp.send( createQueryString() );
}

On Apr 4, 4:25 pm, "FMDeveloper" <fmdeveloper...@gmail.comwrote:
On Apr 3, 11:50 am, "FMDeveloper" <fmdeveloper...@gmail.comwrote:
On Apr 2, 6:39 pm, Ian Collins <ian-n...@hotmail.comwrote:
FMDeveloper wrote:
Adding xmlHttp.setRequestHeader("Content-type","application/x-www-form-
urlencoded"); did not solve the issue.
An example url that would be placed into queryString in
xmlHttp.open("Post", queryString, true) is
http://www.host.com/listing.php?bran...=1175560027602
All I can suggest is you look at the request packets on the wire and
compare the headers sent by each browser.
--
Ian Collins.
Running Apache 1.3.37 - mod_security is disabled, so I will test that
now

THANKS FOR ALL YOUR HELP GUYS! It does appear that mod_security on
Apache 1.3.37 will cause FireFox to return a 403 with the code sample
I provided. Disabling mod_security allows all of the posts to work.

Apr 5 '07 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mark | last post by:
Hi all i was just wondering if you help. I have to send a cgi request to a company using xmlhttp request. They reply back with a line of info but when you view the internet explorer source code...
5
by: Ric | last post by:
I created a page in ASP.Net (with no buffering) that does the following: Output line #1 FLUSH {wait 1 second} Output line #2 {wait 1 second} Output line #3 FLUSH
8
by: rithish | last post by:
I am on IE 6. I was trying out a simple xmlhttp function that send GET/POST requests. However, IE throws an 'unspecified error' when I call the 'setRequestHeader' method. The function that I am...
9
by: balakrishnan.dinesh | last post by:
hi friends, Exactly what i want to know is, In my product we are using xmlhttp request to retrive some data from the server, And Im using IE browser, its working fine in IE. Now i want to work...
1
by: Lu Wei | last post by:
Hello, I'm writing a script to send posts to a web forum. I find that MSXML2.XMLHTTP object could communicate with web server but I can't make it send cookie which is needed for post...
5
by: Prasad | last post by:
Hi all, I wanted to know whether my page is connecting to server or not using xmlHttp request. For that , I am using one condition in onreadystatechange function as.. function xxx() {...
4
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my...
3
by: JMcCrillis | last post by:
I've implemented a FileUpload servlet using AJAX and JS. It appears to be working well but for one issue. I used XMLHTTP so I could intercept the response in Javascript and write it out to a field...
3
by: Andrewh | last post by:
Hi, I am having a bit of a problem with using xmlhttp. The code of the javascript file is shown below used in Windows XP. var xmlhttp = null; function SetURLDiv(url) { if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.