(taking a deeper look)
Your response is HTML. You can drop the whole JSON stuff and use $
("#portfolio_quotes_div_block").html(data) in the callback directly,
no need to parse anything.
This is simple AJAX (or AHAH as some would call it), I think you mixed
up ajax/json/jsonp.
On Mar 31, 12:45 pm, Ricardo <[email protected]> wrote:
> You are trying to parse the response as JSON, but it looks like XML.
> JSON is JavaScript Object Notation (http://www.json.org/js.html).
>
> cheers,
> - ricardo
>
> On Mar 30, 4:08 pm, ckoeber <[email protected]> wrote:
>
> > Hello,
>
> > I am trying to create a JSON service and everything seems to work well until
> > I am pulling the actual data from gthe service to be inserted into a DIV
> > element on a page.
>
> > Here is the code for the JSON service (client side):
>
> > if (Drupal.jsEnabled) {
>
> > $(document).ready(
>
> >
> > function(){
>
> >
> >
> > $("#portfolio_quotes_div_form_block").html('<form
> > id="frmPortfolioSymbolsBlock"
> > name="frmPortfolioAddSymbolBlock" method="post"
> > action=""><label>Symbol<input
> > name="txtSymbol" type="text" id="txtSymbol"
> > size="10" /></label><label><input
> > type="submit" name="cmdAdd" id="cmdAdd"
> > value="Add" /></label><label><input
> > type="submit" name="cmdReloadSymbols"
> > id="cmdReloadSymbols" value="Refresh"
> > /></label></form>');
>
> >
> > //Drupal.settings.portfolio_json_getquotes.uid
>
> >
> >
> > $.post(Drupal.settings.portfolio_json_getquotes.ajaxUrl,{uid:Drupal.settings.portfolio_json_getquotes.uid},
>
> >
> >
> > function (data) {
>
> >
> >
> > var
> > result = Drupal.parseJson(data);
>
> >
> >
> >
> > $("#portfolio_quotes_div_block").html(result);
>
> >
> >
>
> > });
>
> >
> >
> > $("#cmdReloadSymbols").bind("click", function() {
>
> >
> >
> > $.post(Drupal.settings.portfolio_json_getquotes.ajaxUrl,{uid:Drupal.settings.portfolio_json_getquotes.uid},
>
> >
> >
> > function (data) {
>
> >
> > var
> > result = Drupal.parseJson(data);
>
> >
> >
> > $("#portfolio_quotes_div_block").html(result);
>
> >
> >
>
> > });
>
> >
> > return false;
>
> >
> > });
>
> > }
>
> > )
>
> > }
>
> > And here is a sample of the data returned from the working service
> > (the code below is formatted for js):
>
> > "\x3ctable id=\"portfolio_quotes_table_block\"
> > width=\"100%\" border=\"0\" cellspacing=\"0\"
> > cellpadding
> > =\"0\"\x3e\x3ctr\x3e\x3cth
> > scope=\"col\"\x3eSymbol\x3c/th\x3e\x3cth
> > scope=\"col\"\x3eLast\x3c/th\x3e
> > \x3cth
> > scope=\"col\"\x3eChange\x3c/th\x3e\x3c/tr\x3e\x3ctr\x3e\x3cth
> > scope=\"row\"\x3eMSFT\x3c/th\x3e
> > \x3ctd\x3e17.44\x3c/td\x3e\x3ctd\x3e-0.69\x3c/td\x3e\x3c/tr\x3e\x3ctr\x3e\x3cth
> > scope=\"row\"\x3e\x3c
> > /th\x3e\x3ctd\x3e\x3c/td\x3e\x3ctd\x3e\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e"
>
> > Essentially what I am looking for is a table that will be inserted
> > inside a DIV element on the first loading of a page as well as when the
> > refresh button on the form by the JS code above. The code runs but I get the
> > following message:
>
> > uncaught exception: Node cannot be inserted at the specified
> > point in the hierarchy (NS_ERROR_DOM_HIERARCHY_REQUEST_ERR)
>
> > Any ideas?
>
> > Thank you for your time.
>
> > Regards,
>
> > Christopher Koeber
>
> >
>
> > --
> > View this message in
> > context:http://www.nabble.com/Jquery---Weird-Issue-with-%22Node-cannot-be-ins...
> > Sent from the jQuery General Discussion mailing list archive at Nabble.com.