Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parsererror with XmlHtpp-post-request



Stephan,

Are you running your widget on a Leopard developer seed or on Tiger?

In leopard, there is a change to the "content-type" HTTP request header sent by XMLHttpRequest from a webkit-based application (like a widget). This change has been made to match other browsers. In Tiger, this value defaulted to "application/x-www-form-urlencoded", which is appropriate for request bodies containing name=value&name=value pairs (In other words, your typical web form post request). This is a sensible default, but didn't match Firefox, IE, etc. In Leopard, this header value defaults to "application/xml" which is appropriate for request bodies containing XML documents. The case of posting an XML document is much less common, but it's still much more important to match the XMLHttpRequest implementation on other browsers for compatibility.

So bottom line, If you are running a widget on Leopard that makes post requests, you need to decide if you want to override the HTTP content-type header value manually, especially if you are posting name=value pairs. something like this will work:

req.open("POST", "http://www.example.com";);
req.setRequestHeader("Content-Type", "application/x-www-form- urlencoded");
req.send(postData);



See docs below for more XMLHttpRequest info:

http://developer.apple.com/internet/webcontent/xmlhttpreq.html


Todd Ditchendorf Software Engineer email@hidden





On Aug 26, 2006, at 12:37 AM, Stephan Huebner wrote:

Hi,

it's most definitely no javascript-error as when I try to send out the post-request I get back a small html-document that contains just some ttags and a text saying something about a "parsererror". I almost believe it is an error-message generated by webkit or whatever it is that is responding to the request. Though I don't know what could have generated this error-message as I tried out a few post-request-examples from the internet and did exactly what they did for generating the request.

Greetings,

Stephan

On 25.08.2006, at 20:50, Russ White wrote:

what is giving you the parse error? javascript? or xmlhttprequest?

On Aug 25, 2006, at 9:24 AM, Stephan Huebner wrote:

Hi all,

I'm new to this list but not to widget-programming in general. And I'm from Germany, so my Englisch might sound a bit strange sometimes.

So, does anybody know why a post-request using XmlHttpRequest could result in a parsererror? Normal get-requests do work fine, but post-request do not though I think I did everything required including setting of headers for parameters like mime-type, length of data that will be sent with the post-request and so on. I am not sure if is a problem with the post-request itself or maybe with the url I use (maybe the result isn't well-formed or something so that might lead to an parsererror?

Btw, I get the same error if I disconnect the internet, so it rather seems as if this is an error-message built into safari or webkit, but even if, I still don't know what causes this error.

Greetings and thanks in advance,

Stephan Huebner

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/lists% 40russwhite.net


This email sent to email@hidden


-- Love: The only and satisfying answer to the existance of human being -- Sigmund Freud


_______________________________________________ Do not post admin requests to the list. They will be ignored. Dashboard-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Dashboard-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden
References: 
 >parsererror with XmlHtpp-post-request (From: Stephan Huebner <email@hidden>)
 >Re: parsererror with XmlHtpp-post-request (From: Russ White <email@hidden>)
 >Re: parsererror with XmlHtpp-post-request (From: Stephan Huebner <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.