Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers by Nicholas C. Zakas; ISBN: 9780764579080
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 19th, 2006, 03:20 AM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question on HTTP Post

Hi,
I just got your book “JavaScript for Web Developers”. The main reason I purchased it was to get get a better understanding of the http Requests in chapter 16. I was able to make the GET examples to work great. The POST example on page 505 (CrossBrowserHttpRequestExample2.htm) however doesn’t seem to work for me. The program runs without error but the data from the server (oRequest.responseText) is empty. I place several alert messages in the JavaScript and found that the oRequest.onreadystatechange is equal to 4, the oRequest.responseText is empty, and the oRequest.status is 405.

I have modified the sURL and verified that it is correct. I have moved this onto a development server from my local server to eliminate any issues there.

Any ideas on what I might look at next to debug this.


Thanks,
Dan
Reply With Quote
  #2 (permalink)  
Old December 19th, 2006, 01:48 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

A status of 405 indicates that the method isn't allowed on the specified resource. This usually occurs if you try to send a POST request to a file type that can't do server-side logic, such as a plain text file. Try posting to a PHP file (I'm not sure, but it may even work with a regular HTML file) and it should work fine.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #3 (permalink)  
Old December 20th, 2006, 01:18 AM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, the PHP file was the problem, I replaced it with and asp file and it now works for IE but I still have a problem with Netscape.

Using Netscape, I make it to onreadystatechange function. The program starts to execute the onreadystatechange and then terminates. To look at this I placed a couple of alert statements in the code. By monitoring the oRequest.readyState I see that in IE I get an alert for 2, 3, and then 4 which then continues to completion of the program. In Netscape I get a 1, then a 2 and the program terminates.

Any ideas what may be wrong with Netscape? I have included the onreadystatechange code below I am monitoring.

        oRequest.onreadystatechange = function () {
            if (oRequest.readyState == 4) {
            alert(oRequest.readyState + ":" + oRequest.responseText + ":" + oRequest.status );

                fnCallback(oRequest.responseText);
            }
        alert(oRequest.readyState);
        }


Thanks,
Dan
Reply With Quote
  #4 (permalink)  
Old December 20th, 2006, 02:03 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Sorry, I haven't used Netscape in a very long time, so I'm not sure why it specifically would have a problem. The most likely issue is some kind of error. You should check the status property for a better indication of what might possibly be wrong.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP post silver_scar C# 2005 0 July 31st, 2006 09:52 AM
HTTP POST/GET d_alchemist JSP Basics 1 April 24th, 2006 09:18 AM
XML HTTP Post acdsky Servlets 2 June 2nd, 2005 10:59 AM
HTTP-POST with C# jcascio ASP.NET 1.0 and 1.1 Professional 3 April 12th, 2004 01:15 PM
HTTP Post .Net sjlsysprg1 Pro VB.NET 2002/2003 5 June 26th, 2003 12:20 PM



All times are GMT -4. The time now is 01:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.