[jQuery] Re: yet again XML+jQuery+IE7

2008-07-17 Thread Diego A.
I'm not sure it's a bug... :-S
Personally, I think it's best practice to use something along the lines of
the text2html function I posted (below)

// Convert text to XML DOM
var text2xml = function(s) {
 var x, ie = /msie/i.test(navigator.userAgent);
 try{
  var p = ie? new ActiveXObject(Microsoft.XMLDOM) : new DOMParser();
  p.async = false;
 }catch(e){ throw new Error(XML Parser could not be instantiated) };
 try{
  if(ie) x = p.loadXML(s)? p : false;
  else x = p.parseFromString(s, text/xml);
 }catch(e){ throw new Error(Error parsing XML string) };
 return x;
};


2008/7/16 Tzury [EMAIL PROTECTED]:


  Yeah it's a kind of bug in jQuery ...
 
  I dealt with this issue one month ago and the solution was to convert
  it into JSON

 the way I am planning to approach is by building in-memory DOM element
 and injecting the XML into it.

 example:
 var el = document.createElement('div');
 el.innerHTML = xml;
 alert(el.firstChild.innerHTML);

 utilizing jQuery facilities for DOM traversing is the next obvious
 step.

 hope someone will notice this and file a bug for the dears jQuery
 developers.




-- 
Cheers,
Diego A.


[jQuery] Re: yet again XML+jQuery+IE7

2008-07-16 Thread Tzury

 If that's the exact code you're using, then you should first convert the XML
 string into a jQuery object, like this...

 xml = $(' {xml goes here} ');



Diego, John
I changed my snippet as follows and it is still works only in FF, not
in IE7

script src=jquery.js/script
script
var xml = NewDataSet
  + Table1
  +  aHello/a
  +  bjQuery/b
  + /Table1
+ /NewDataSet;
xml = $(xml);
alert($(Table1, xml).text());
/script


[jQuery] Re: yet again XML+jQuery+IE7

2008-07-16 Thread Tzury

 xml = $(' {xml goes here} ');


added xml = $(xml); (see below)
still not working on IE7

script src=jquery.js/script
script
var xml = NewDataSet
  + Table1
  +  aHello/a
  +  bjQuery/b
  + /Table1
+ /NewDataSet;

xml = $(xml);

alert($(Table1, xml).text());

/script


[jQuery] Re: yet again XML+jQuery+IE7

2008-07-16 Thread koko

Yeah it's a kind of bug in jQuery ...

I dealt with this issue one month ago and the solution was to convert
it into JSON


[jQuery] Re: yet again XML+jQuery+IE7

2008-07-16 Thread Tzury

 Yeah it's a kind of bug in jQuery ...

 I dealt with this issue one month ago and the solution was to convert
 it into JSON

the way I am planning to approach is by building in-memory DOM element
and injecting the XML into it.

example:
var el = document.createElement('div');
el.innerHTML = xml;
alert(el.firstChild.innerHTML);

utilizing jQuery facilities for DOM traversing is the next obvious
step.

hope someone will notice this and file a bug for the dears jQuery
developers.


[jQuery] Re: yet again XML+jQuery+IE7

2008-07-15 Thread Diego A.
Hi Tzury,

I've just released a plugin to work around XML parsing issues by converting
it to JSON. Tested in IE6/7, FF2/3. You might find it useful.

XML 2 JSON Plugin
http://www.fyneworks.com/jquery/xml-to-json/

Cheers,
Diego A.

2008/7/15 Tzury [EMAIL PROTECTED]:


 the following example  (taken from:
 http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery)
 works fine in FF but not in IE7

 dose anyone find a way to make jQuery XML parsing facilities work on
 IE as well?


  $(document).ready(function() {
   // generate markup
   $(#rating).append(Please rate: );

   for ( var i = 1; i = 5; i++ )
 $(#rating).append(a href='#' + i + /a );

   // add markup to container and apply click handlers to anchors
   $(#rating a).click(function(e){
 // stop normal link click
 e.preventDefault();

 // send request
 $.post(rate.php, {rating: $(this).html()}, function(xml) {
   // format and output result
   $(#rating).html(
 Thanks for rating, current average:  +
 $(average, xml).text() +
 , number of votes:  +
 $(count, xml).text()
   );
 });
   });
  });




-- 
Cheers,
Diego A.


[jQuery] Re: yet again XML+jQuery+IE7

2008-07-15 Thread John Resig

Hey - can you provide an example site? It's unclear what might be
wrong without seeing a response from the server. What is the value of
xml when it comes back?

--John


On Tue, Jul 15, 2008 at 9:34 AM, Tzury [EMAIL PROTECTED] wrote:

 The following example (from the jquery-doc-site) works fine with
 firefox.
 however, in IE7  $(element_name, xml).text() returns empty-string
 anyone bypassed this issue in the past?

  $(document).ready(function() {
   // generate markup
   $(#rating).append(Please rate: );

   for ( var i = 1; i = 5; i++ )
 $(#rating).append(a href='#' + i + /a );

   // add markup to container and apply click handlers to anchors
   $(#rating a).click(function(e){
 // stop normal link click
 e.preventDefault();

 // send request
 $.post(rate.php, {rating: $(this).html()}, function(xml) {
   // format and output result
   $(#rating).html(
 Thanks for rating, current average:  +
 $(average, xml).text() +
 , number of votes:  +
 $(count, xml).text()
   );
 });
   });
  });



[jQuery] Re: yet again XML+jQuery+IE7

2008-07-15 Thread Tzury



On Jul 15, 5:53 pm, John Resig [EMAIL PROTECTED] wrote:
 Hey - can you provide an example site? It's unclear what might be
 wrong without seeing a response from the server. What is the value of
 xml when it comes back?

 --John


below is a snippet which can be tested in FF and IE

script src=jquery.js/script

script

var xml = NewDataSet
  + Table1
  +  aHello/a
  +  bjQuery/b
  + /Table1
+ /NewDataSet;

alert($(Table1, xml).text());

/script


[jQuery] Re: yet again XML+jQuery+IE7

2008-07-15 Thread Diego A.
Hi Tzury,

If that's the exact code you're using, then you should first convert the XML
string into a jQuery object, like this...

xml = $(' {xml goes here} ');

Hope that helps.

Diego A.

2008/7/15 Tzury [EMAIL PROTECTED]:




 On Jul 15, 5:53 pm, John Resig [EMAIL PROTECTED] wrote:
  Hey - can you provide an example site? It's unclear what might be
  wrong without seeing a response from the server. What is the value of
  xml when it comes back?
 
  --John
 

 below is a snippet which can be tested in FF and IE

 script src=jquery.js/script

 script

 var xml = NewDataSet
  + Table1
  +  aHello/a
  +  bjQuery/b
  + /Table1
 + /NewDataSet;

 alert($(Table1, xml).text());

 /script




-- 
Cheers,
Diego A.