Browser doesn't renders table element | jsFiddle example
Browser doesn't renders table element | jsFiddle example
My code makes a cross domain request to fetch the source of a webpage, using James Padolsey's "cross domain mod for jQuery": https://github.com/padolsey/jQuery-Plugins/tree/master/cross-domain-ajax;
Then it selects the first table and appends it to a existing div.
But the appended table doesn't get rendered properly. Can anyone take a look at this fiddle and tell me why?
http://jsfiddle.net/6ZgRf/
stripViewResponse(res.responseText);
function stripViewResponse(antwort) {...
I know that. But your are right, others maybe won't. So thanks for the hint. Here is the updated jsFiddle: jsfiddle.net/zjy73
– John
Oct 5 '12 at 18:42
2 Answers
2
You're using jQuery.. so you can traverse it by turning it into a jQuery object
function stripViewResponse()
// Select table element
var fetchedTable = $(antwort).find('table')[0]; // find first table
// append table
$('#new').append(fetchedTable);
http://jsfiddle.net/6ZgRf/1/
Awesome! As you can see I'm just getting started. Thank you very much.
– John
Oct 5 '12 at 17:48
You can also try this
function stripViewResponse()
// Select table element
var fetchedTable = $(antwort).find('table').eq(0);
// append table
$('#new').append(fetchedTable);
Thanks! It's almost the same as @wirey suggested.
– John
Oct 5 '12 at 18:14
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Side note, don't use a global variable to communicate the response from one function to another. Pass it as an argument:
stripViewResponse(res.responseText);
and receive it as a parameterfunction stripViewResponse(antwort) {...
– I Hate Lazy
Oct 5 '12 at 17:57