Index: /CKEditor/trunk/CHANGES.html
===================================================================
--- /CKEditor/trunk/CHANGES.html	(revision 5143)
+++ /CKEditor/trunk/CHANGES.html	(revision 5144)
@@ -101,4 +101,5 @@
 		<li><a href="http://dev.fckeditor.net/ticket/5140">#5140</a> : In High Contrast mode, arrows will now be displayed for menus with submenus.</li>
 		<li><a href="http://dev.fckeditor.net/ticket/5163">#5163</a> : The undo system was not working on some specific cases.</li>
+		<li><a href="http://dev.fckeditor.net/ticket/5162">#5162</a> : The ajax sample was throwing errors when loading data.</li>
 		<li>Updated the following language files:<ul>
 			<li><a href="http://dev.fckeditor.net/ticket/5006">#5006</a> : Dutch;</li>
Index: /CKEditor/trunk/_samples/ajax.html
===================================================================
--- /CKEditor/trunk/_samples/ajax.html	(revision 5143)
+++ /CKEditor/trunk/_samples/ajax.html	(revision 5144)
@@ -29,15 +29,17 @@
 	// Create a new editor inside the <div id="editor">
 	editor = CKEDITOR.appendTo( 'editor' );
-	editor.setData( html );
+	editor.setData( html, null, true );
 
 	// This sample may break here if the ckeditor_basic.js is used. In such case, the following code should be used instead:
 	/*
 	if ( editor.setData )
-	editor.setData( html );
+		editor.setData( html, null, true );
 	else
-	CKEDITOR.on( 'loaded', function()
 	{
-	editor.setData( html );
-	});
+		CKEDITOR.on( 'loaded', function()
+			{
+				editor.setData( html, null, true );
+			});
+	}
 	*/
 }
Index: /CKEditor/trunk/_source/plugins/undo/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/undo/plugin.js	(revision 5143)
+++ /CKEditor/trunk/_source/plugins/undo/plugin.js	(revision 5144)
@@ -121,12 +121,12 @@
 	function Image( editor )
 	{
-		var selection = editor.getSelection();
-
-		this.contents	= editor.getSnapshot();
+		var contents	= editor.getSnapshot(),
+			selection	= contents && editor.getSelection();
+
+		// In IE, we need to remove the expando attributes.
+		CKEDITOR.env.ie && contents && ( contents = contents.replace( /\s+_cke_expando=".*?"/g, '' ) );
+
+		this.contents	= contents;
 		this.bookmarks	= selection && selection.createBookmarks2( true );
-
-		// In IE, we need to remove the expando attributes.
-		if ( CKEDITOR.env.ie )
-			this.contents = this.contents.replace( /\s+_cke_expando=".*?"/g, '' );
 	}
 
@@ -351,4 +351,8 @@
 			if ( !image )
 				image = new Image( this.editor );
+
+			// Do nothing if it was not possible to retrieve an image.
+			if ( image.contents === false )
+				return;
 
 			// Check if this is a duplicate. In such case, do nothing.
