0

I'm using CodeKit and would like to continue to do so, and thus I haven't got any access to PHP. So what I would like to do is basically include a plain external .html file locally or on the codekit server with javascript.

The idea is to have an if statement and if foo=true then write out foo.html, else write out no-foo.html.

How do I do this?

Mikael
  • 97
  • 1
  • 7

1 Answers1

0

Provided you have jQuery tagged in your question, you can use it's $.get implementation, which is a higher level version of the $.ajax function except $.get is limited to GET requests, which is likely what you need.

When using Ajax, you're sending an asynchronous HTTP request to something on the server, this may be a HTML document, or chunk of HTML code, anything that the server responds with on a specific request can be used.

$.get('/data/foo.html', function(data){
  $('.bar').html(data);
});