$.get and rebinding

$.get and rebinding

Hi,

so I have the same problem that gazillions of other users seem to have: I cannot figure out how to rebind an event after an AJAX-call.

I have a page (let's call it "name.php") with an ordinary HTML 

  1.       <select name="lastname" onChange="nameChanged(this);"> 

dropdown. The function nameChanged() itself does an AJAX call (simplified like this):

  1. function nameChanged(currentElement) {
  2.       // alert ('test');
  3.         $.get('doSomething.php', { 'last_name': currentElement.value },
  4.    function(data){
  5.      document.form.name_repeat.value = data.first_name;
  6.    }, 'json');
  7.    }

This works fine as long as I call the script "name.php" directly. If "name.php" gets called from another script (let's say, "big.php") via AJAX and gets inserted into a DIV, the $.get call no longer works. If I uncomment the alert in line 2, however, THAT works, so the nameChanged()-function fires.

It seems to me that I need to rebind the $.get-call somehow, but to what? And how? 

I don't understand how global jQuery-calls like this work, I think. It seems to me that this $.get call should fire whenever it is encountered and is not bound to anything. Am I wrong?

Thank you for your help,
Matthias