tags:

views:

239

answers:

1

I am trying to call a jquery function which is intiated when the user clicks enter button on an input text control .The return value is an url which will be used to redirect to a different page.The code given below is not working.Please help Thks

<script type="text/javascript">
$(function()
{
    $('#Text1').keypress(function(e)
    {
         if (e.which == 13) 
         {
              $.get('text.ashx',{
                       term:$(this).val()
                   },
                   function(data){
                        javascript:window.location =data;
              });
         }
    });
});  
</script>

<form id="form1" runat="server">
<div>
    <input id="Text1" type="text" />

</div>
</form>
+2  A: 

Get rid of the javascript: before you set the location.href.

<script type="text/javascript">
$(function()
{
    $('#Text1').keypress(function(e)
    {
         if (e.which == 13) 
         {
              $.get('text.ashx', {
                       term: $(this).val()
                   },
                   function(data){
                        window.location = data;
                   }
              );
         }
    });
});  
</script>
tvanfosson
thks... that worked!!!!