I want to load code and display it inside code tags (for syntax highlighting, etc.) like this:
<pre><code>alert("javascript loaded");</code></pre>
I am doing this in jQuery right now:
$.ajax({
url: "/local/path.js",
success: function(data) {
alert("success");
var code = $("<pre><code>" + data + "</code></pre>");
$("body").append(code);
}
})
...where "/local/path.js"
is some code snippet we want to show as part of a blog post but don't want it to execute:
# /local/path.js (or /local/path.programming-language-ext)
alert("javascript loaded");
The problem is, before alert("success");
is even called, alert("javascript loaded");
is called. That shouldn't be executing, I want to load just a raw string. That is, I don't want jQuery to do any sort of processing on the response. How do I do that? This is all done without any server-side language.