1

Don't know whats exactly going on, but it's definitely killing my time for nothing. Here's my javascript function :

<script type="text/javascript"  >

function loadSponsorName() {
    var sp_id = document.getElementById('sponsor_id').value;
    var murl = 'load_sponsor.php?sp_id='+sp_id+'';

    var a=new Ajax(murl,{
        method:"post",
        onComplete: function(response){
        $('sponsorName').setHTML(response); 
        }
    }).request();
}
</script>

and inside a form this are my inputs

<tr>
    <td width="33%" height="20">
        <label id="namemsg" for="name">Sponsor ID:</label>
    </td>                          
    <td width="67%">
        <input type="text" name="sponsor_id" id="sponsor_id" size="40" value="" class="inputbox required" maxlength="50" onkeyup="loadSponsorName();" /> *
    </td>
</tr>
<tr>
    <td height="20">
        <label id="namemsg" for="name">Sponsor Name:</label>
    </td>                          
    <td><div id="sponsorName">
        <input type="text" name="sponsor_name" id="sponsor_name" size="40" value="" class="inputbox required" maxlength="50" /> *
    </div></td>
</tr>

It seems the onkeyup event is not even calling the function.

Can somebody help me?

2
  • if you write onkeyup="alert(1)" - it works? Commented Nov 24, 2011 at 15:00
  • it works for me - jsfiddle.net/x5t3b Commented Nov 24, 2011 at 15:18

2 Answers 2

1

onkeyup is working try this javascript code to see how works;

function loadSponsorName() {
       alert(document.getElementById('sponsor_id').value);
}

I think there is a problem with;

 var a=new Ajax(murl,{
            method:"post",
            onComplete: function(response){
            $('sponsorName').setHTML(response); 
            }
        }).request();

Where is Ajax class? Did you import it from an other lib?

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. That's right. But can you tell what library I can use for the code to work? I've a project that have this code and works fine. But when I imported to my project, it doesn't... I cant find any, but I think I'm missing the library you are referring...
Maybe these three lib meet your needs; api.jquery.com/jQuery.ajax and prototypejs.org/api/ajax/request and tutorialspoint.com/prototype/prototype_ajax_request.htm or you must find Ajax class from your previous project
Hey :) Thats the perfect answer! I was missing the library and thats mootools.js. THANKS A LOTT!
0

Ajax call in the handler + "handler not working aaaaaarghhhhh hellpppp" = usually means a not working Ajax call.

I am not sure what library you are using for your Ajax call, but try to add something like an onError callback function there where you are adding onComplete. I bet that will be called because there is a problem with the Ajax call.

2 Comments

I'm using <script type="text/javascript" src="ajax.googleapis.com/ajax/libs/jquery/1.4.2/…>
"I am not sure what library you are using for your Ajax call" - Is there any library required for this type of call? please let me know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.