• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to include quotes in jquery

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to update a piece of a webpage via JQuery.

This works:


This doesn't work: (This is from an AJAX action so I don't get an error message._


At first, I thought the problem had to do with the quotes. (Although I would think backslashing the quote would already escape it.) Then I thought mixing the JavaScript quote types would help. The following didn't work either though.


Is there a better way of mixing the quotes? Or am I looking down the wrong path?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tried it using jquery-1.2.3 with no difficulties. What error are you seeing?

My test file:


Firebug HTML display:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. It's just a matter of style (and completely unrelated to your issue), but I would have coded it as:
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
I just tried it using jquery-1.2.3 with no difficulties. [/CODE]

That example works for me too. Looks like my hunch about the quotes was wrong. I tried some other HTML strings to further "guess" at the problem.
Works: $("#message").html("<b>test<\/b>");
Fails: $("#message").html("<li>test<\/li>");

This means you are right that the quotes have absolutely nothing to do with it. Neither does the HTML symbols since the bold one works. (<input> was never in my examples - I just used it to simplify which might have obscured things.)


What error are you seeing? ]

Tomorrow, I'm going to try to reproduce the problem without involving AJAX so I can actually see an error and more of what's going on.


[QBP.S. It's just a matter of style (and completely unrelated to your issue), but I would have coded it as[/QB]

That's good to know for the future. I didn't write this particular line of code. And it looks like it needs to be written this way as it is really outputting some dynamic HTML so I don't know the tag/attribute in advance.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The standalone file was very helpful. I was able to try the same thing that "didn't work" standalone and it "did work". This is good as the problem doesn't lie with using JQuery and it's likely something else on the page. I'll look around some more at that end.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And now I've got it working. Turns out the problem had absolutely nothing to do with JQuery or AJAX.

I am using a filter with HtmlParser to do some transformations. I needed to turn it off for this case because it was corrupting the AJAX result - which was not HTML and just looked like it.

I did learn a lot doing this so it was a good exercise though.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64721
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very cool, Jeanne!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic