| Author |
how to include quotes in jquery
|
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
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?
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
|
I just tried it using jquery-1.2.3 with no difficulties. What error are you seeing? My test file: Firebug HTML display:
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56549
|
|
P.S. It's just a matter of style (and completely unrelated to your issue), but I would have coded it as:
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26496
|
|
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
Joined: Jan 10, 2002
Posts: 56549
|
|
|
Very cool, Jeanne!
|
 |
 |
|
|
subject: how to include quotes in jquery
|
|
|