Problem with fin() and each()

Problem with fin() and each()

The code will:
1. Gets the current url
2. Find the current url in xml
3. Returns a new url and redirects to it
 What's is the error?

  1. $(document).ready(function () { $("#leerxml").click(function () { var urlactual = document.location.href; $.get("students.xml", {}, function (xml) { $(xml).find("urldirige").each(function () { if ($(this).find("url").text() == urlactual) { //do something document.location.href = $(this).find("reserva").text(); } }); }); }); });