I copied HTML using .clone(true, true) because I want to keep the JQuery event handlers. When I pass this to PHP via $.post the post fails and gives me the following error in firebug
uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: jquery-1.7.2.js :: <TOP_LEVEL> :: line 7740" data: no]
I want to somehow keep the HTML and its JQuery event handlers because I am working on writing a script to save the state the user is in.
UPDATE (Added Code)
//Save HTML w/ JQuery
GSaveState = new Object();
GSaveState['HTML'] = $('#content').clone(true, true);
$.post("DecoPOState.php", { SavedState: GSaveState},
function(data){
alert("Test");
}
);
The problem with your code is that you try to send a DOM element – you cannot do that for obvious reasons. Assuming that you want to send the HTML code of that element, use
$('#content').html()However, event handlers are not contained in that string since they are attached to the element and not inline event (i.e. they aren’t attributes that appear in the DOM tree).
To save the application’s state event handlers should not be important at all though. Use variables for the state information you want to save and include them in your POST data.