How to find iframe inside a div ?

Problem: I need to find an iframe inside a div and then an element inside that iframe.

It’s easy with JQuery:

<div class="container">
    <iframe frameborder="0" src="javascript:void(0)" role="listbox" aria-label="tag" title="tag">
        <div id="div-inside-iframe"></div>
$('.container iframe').contents().find('#div-inside-iframe');

Javascript is not working on content loaded by jquery’s .get()

IE made me cry again.

Problem: When you want to load some html data into document using JQuery’s .get() .post() .ajax() functions but events like “onclick, onmouseover” don’t work exactly inside loaded content in all versions of Internet Explorer.

1. Check carefully if loaded html is valid with any online validator.
In my case IE didn’t show errors and even notices, for some reason, so it’s always better to check html with other online tools.

2. Use jquery .live() function to bind events.

$('#foo').live('click', function() {
  alert('User clicked on "foo');

3. Other developers suggest also to avoid <script> tags inside loaded content.

Well, probably they are right, but it worked for me without moving those.

See “.bind()” documentation at

Nearly the same problem was described at

Permalink is not working in wordpress

If you always get 404 error after changing permalink structure try to check if:

  1. .htaccess file is in the web site root, normally in the same directory where index.php is.
  2. Is .htaccess is readable by web-server.
    The simplest and fastest way to check that is to add an extra line with random text and save it. If you see 500 error then it’s readable. Do not forget to remove extra text.
  3. Is “Rewrite Engine” enabled. Usually it’s enabled by default on majority hosting servers otherwise you should get error 500.
  4. If “Rewrite Engine” works ok but the above did not help you can try this code in your .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(js|ico|gif|jpg|png|css|php|html|src|pdf|zip|txt|doc|docx)$ index.php [L]

Simple site pinger

This simple script pings your websites and notifies when a website is down.
It’s written in python >= 2.5 and might be usefull for administrators and programmers.
Some parts of it was found somewhere in the internet and adjusted a bit for my needs.

Required packages can be installed easily from repository ( Ubuntu example ):

sudo apt-get install python-notify

or using pip/easy_install as well

sudo pip install notify

Running this script from command line is a bit annoying so I put to run it by crontab each 30 min:

$ crontab -e
*/30 * * * * DISPLAY=:0 /usr/bin/python /home/vs/bin/

Note that you need to set DISPLAY option to make notification visible for current X session.

#!/usr/bin/env python
from threading import Thread
import subprocess
from Queue import Queue
from pynotify import *

num_threads = 4
queue = Queue()
hosts = [
#wraps system ping command
def pinger(i, q):
    """Pings subnet"""
    while True:
        host = q.get()
        #print "Thread %s: Pinging %s" % (i, host)
        ret ="ping -c 5 %s" % host,
                        stdout=open('/dev/null', 'w'),
        if ret == 0:
            #print "%s: is alive" % host
            init("Server checker")
            msg =  "%s: did not respond" % host
            Notification("Server checker", msg).show()
#Spawn thread pool
for i in range(num_threads):

    worker = Thread(target=pinger, args=(i, queue))
#Place work in queue
for host in hosts:
#Wait until worker threads are done to exit

“Pending” status in the browser when trying to send data through ajax.

When I tried to send some data to a server using jquery .post() method, I got the “Pending” status in Chrome’s or Firefox network monitoring tool and finally did not get response from the server. I’ve never met such a strange behavior of sending data via ajax, so that was not obvious problem for me.
Later I found out that the data size was about 1Mb, because one hidden field of the form contained a lot of html data.
I used $(“#myform”).serialize() to post all the data from the form.
Then it was necessary to collect values separately, because I needed each field to be tested by size.
Here is a piece of code:

        to_pdf = $("#main").html() // size of html data was about 1Mb
        //to_pdf = to_pdf.substr(0, to_pdf.length/3) this still causes "Pending" status
        //reduce size of data just for test
        //to_pdf = to_pdf.substr(0, 40000) this works but with 5 seconds delay. 

        $.post("/layout-builder/generate-pdf/", { 
               to_pdf_data: to_pdf,
        }, function(response){
               $.get("/layout-builder/preview-with-real-values/id/"+$("#invoice_id").val()+"/", false, previewHtmlCallBack, 'json');
           }, 'json');

Reducing the size of posted data by removing unnecessary html code from #main div solved the problem for me.