[mochikit] Re: Async request problem on Safari
The issue here turned out to be Safari's behavior with respect to inserting parts of one document into another. Firefox 2.0 doesn't mind directly inserting content from one document into another although it appears that Firefox 3.0 won't support it. Apparently the correct way to do it is to use importNode (DOM L2 or L3) or adoptNode (L3). When I started using importNode on the content of responseXML things started working in Safari. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Async request problem on Safari
No matter what I put in that XML declaration, Safari only returns something for responseText (tested on both Leopard and Windows). I tried the DOMParser suggestion but I can't get it to work either -- there must be something wrong with the xml string but I can't figure it out (yet). Thanks again for taking a look at this and for your suggestions. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Async request problem on Safari
Have you tried using doXHR with the mimeType: 'text/xml' option? Take a look at the ajax_tables or interpreter examples for usage. On Dec 29, 2007 9:50 AM, Steve Zatz [EMAIL PROTECTED] wrote: No matter what I put in that XML declaration, Safari only returns something for responseText (tested on both Leopard and Windows). I tried the DOMParser suggestion but I can't get it to work either -- there must be something wrong with the xml string but I can't figure it out (yet). Thanks again for taking a look at this and for your suggestions. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Async request problem on Safari
Have you enabled debugging in Safari? Does the console show any error messages? Per, thanks for the reply. I should have added that I do have debugging enabled and there are no errors. I'll look into using responseXML directly -- I think the XML is OK or maybe it's just that Firefox and IE are more relaxed about it. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Async request problem on Safari
- Make sure you're setting the Content-Type header to text/xml. - Probably don't need to use documentElement - try response = res.responseXML.documentElement || res.responseXML ; - The namespace declaration on the p element could be causing problems. Does it work without it? What about var p = response.getElementsByTagNameNS('*','p')[0]; ? Hamish, thanks for the advice -- still not there but getting closer. So here is what I know from using the Drosera debugger: - Safari is getting the response but there is no responseXML only a responseText so for some reason it appears to believe that what the server is sending isn't valid xml. - res.getAllResponseHeaders() looks like: Date: Sat, 29 Dec 2007 04:00:00 GMT Content-Length: 78 Server: CherryPy/3.0.2 Content-Type: text/xml So the Content-Type looks fine. - res.responseText has the value: ?xml version=1.0 standalone='yes'?responseid522/idpabc/p/response which looks like fine XML to me. (I did drop the namespace declaration and the encoding to see if that made a difference - it didn't.) So I am stumped -- the content-type appears correct, the server appears to be sending valid xml but Safari only populates the responseText and not responseXML. Since I really do want to pass XML and manipulate it via DOM, I need to try to find out why Safari won't populate responseXML. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Async request problem on Safari
Have you enabled debugging in Safari? Does the console show any error messages? From some examples I found, it looks like people use res.responseXML directly, without the .documentElement part. I guess you should also check for malformed XML in the response. Here is some relevant documentation from Apple Developer Connection: More powerful, however, is the XML document object in the responseXML property. This object is a full-fledged document node object (a DOM nodeType of 9), which can be examined and parsed using W3C Document Object Model (DOM) node tree methods and properties. Note, however, that this is an XML, rather than HTML, document, meaning that you cannot count on the DOM's HTML module methods and properties. This is not really a restriction because the Core DOM module gives you ample ways of finding element nodes, element attribute values, and text nodes nested inside elements. /Per On Dec 28, 2007 12:49 AM, Steve Zatz [EMAIL PROTECTED] wrote: First of all, I am an inexperienced javascript programmer (so you're forewarned) and appreciate any help with the following problem. I have googled this every which way but can't find anything relevant. I am using the current trunk of Mochikit. I have a simple Web application that lists items and I am using AJAX to display a detailed note on a particular item if the user requests it. The application works as expected for IE and Firefox but does not work on Safari (version 3.0.4 running on Leopard). When the user requests a note on an item, the following javascript function is executed: function show_note(obj) { var id = obj.parentNode.id; var res = doSimpleXMLHttpRequest('get_note/'+id); res.addCallback(show_note_response); } and show_note_response looks like: function show_note_response(res) { var response = res.responseXML.documentElement; var id = response.getElementsByTagName('id')[0].firstChild.data; var p = response.getElementsByTagName('p')[0]; var note_div = DIV({'id':id+'d','class':'note'},p) appendChildNodes(id, note_div); //id is the id of the item that was clicked on } When using Safari (or IE or Firefox), I can see the server receive the 'get_note' request and I can see the server respond with something like: ?xml version=1.0 encoding=UTF-8 standalone=yes?responseid627/idp xmlns=http://www.w3.org/1999/xhtml;Some text .../p/response When using IE and Firefox the note displays below the item as expected but on Safari nothing happens and I am not sure what the problem is or how to debug it. Thanks for any suggestions. Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups MochiKit group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---