2

Ok this is frustrating... The code below works "correctly" as far as sending the email address to the SaveEmail URL and it gets saved correctly each time I change the drop down. However it only outputs the "Successful" message once, no matter how many times I change the value in the drop down. The "data" that is returned is "Successful". I would like to show the message for a couple seconds, then fade it out. It works correctly the first time I change the drop down, after that the change happens and the value gets saved, but the "Successful" message doesn't display.

jQuery code:

$('#AgentEmails').change(function() {
  var NewAddress = $('#AgentEmails').val();
  $.post('SaveEmail.aspx', { email: NewAddress }, function(data) {
    $('#SelectMsg').html("<b>" + data + "</b>").fadeOut();
  });
});

HTML code:

<select ID='AgentEmails' runat='server'>
  <option value="[email protected]">TEST</option>
</select><span id='SelectMsg'></span>

What needs to be changed in my code to make this operate correctly? Thanks for the help.

2
  • NewAddress reaches the server successful every time? Commented May 25, 2010 at 13:26
  • Yes, I make many changes during testing and check the DB each time. Commented May 25, 2010 at 13:35

2 Answers 2

3

Once fadeOut is executed, the display property of #selectMsg is set to none, so you won't see it again, unless you restore it's visibility. For example:

$('#AgentEmails').change(function() {
  var NewAddress = $('#AgentEmails').val();
  $.post('SaveEmail.aspx', { email: NewAddress }, function(data) {
    $('#SelectMsg').show();
    $('#SelectMsg').html("<b>" + data + "</b>").fadeOut();
  });
})
Sign up to request clarification or add additional context in comments.

2 Comments

nice focus on the actual issue and not side tracked by "what else" :)
Thanks. I suppose that could be chained into the original statement ahead of the ".html".
0

the selection ain't made correctely in asp.net there is a couple of different ways to make selection by jquery you shoudl try this code:

$("*[id$='AgentEmails']").change(function() {
  var NewAddress = $("*[id$='AgentEmails']").val();
  $.post('SaveEmail.aspx', { email: NewAddress }, function(data) {
    $("*[id$='SelectMsg']").html("<b>" + data + "</b>").fadeOut();
  });
});

3 Comments

that makes no sense if what the OP says is true. Data is saved at all times so selection must be correct.
@jAndy: That wasn't me. I just indented the code so it was formatted correctly.
i used jquery in my previous projects, and i can't select with the commmon way, i've had to google a little to find some tricks, but if he is using VS2010 the code above is useless.

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.