3. scraping my self


While thinking about how do I pre-generate the "Email send, thank you." and "Email send error, please try again later." feedback AJAX responses I realized I don't. :-) I use the statically generated response pages and just web-scrape them.

The interresting part from feedback.js:

// setup feedback submit event
$('#feedback_form').submit(function() {
            name: $('#formName').attr('value'),
            email: $('#formEmail').attr('value'),
            subject: $('#formSubject').attr('value'),
            message: $('#formMessage').attr('value')
        function (data) {
            $('#content_inside_main .error')
                .find('#content_inside_main .error'));
            $('#content_inside_main .info')
                .find('#content_inside_main .info'));

    return false;

First the submit of a form is hijacked and instead an AJAX post is issued. The CGI that is handling the POST is redirecting to either email-ok.html or email-fail.html. This pages are generated for non-JavaScript capable (disabled) browsers. After the AJAX call is successful function (data) {}; is called. The data variable is filled with the HTML. Then just content of #content_inside_main .error and #content_inside_main .info elements is replaced with the content of the same elements from data.

Fun huh? In this case yes, but in other the same technique is saving >300MB of content that will have to be pre-generated. But let's show that case some other time.

comments powered by Disqus