views:

136

answers:

2

I have not used jquery much yet and not very familiar with it.

Trying to do the below:

// JavaScript Document

$(document).ready(function()
{
    $('#day').change (function () 
    {

//next to lines work here but not if placed after $.get

     var day =  $('#day').val() ;

 $("#test").html(day);

     $.get('http://www.sharingizcaring.com/schedule/menutest.php', { day: $('#day').val() },      
        function(data) 
     {
          $("#test").html( data );
      });
    });    
});

Setting the .html to blah blah works.. But if I switch actions to use the value of the select item #day

day is a <select> tag.

Also the code works correctly above the $.get() function.

It does not work.

+1  A: 

Ordinarily, I would expect that you would set the value on return to something you got back from the server. To do that you need to add a parameter to your callback function and reference the value on it. I'm going to assume that your menutest method returns HTML containing the "new" day input.

$.get('http://www.sharingizcaring.com/schedule/menutest.php',
      { day: $('#day').val()  },      
      function(data) {
          $("#test").html( data );
      }
);
tvanfosson
day is a <select> so it just gets the value of that.. menutest.php doesn't do anything yet but that might be part of my problem
ian
You might want to show a bigger code snippet. The value of the select shouldn't be different depending on where you grab the value.
tvanfosson
Put in the full code...
ian
+1  A: 

Could be the problem with the url you are sending a request to. I think it should be the same domain s the page, otherwise it wont work. Also, try using Firebug to see if requests get sent and what is returned. Firebug is realy helpfull.

gregor
Hhmm thanks I tried that out and ended up the script runs perfect in firefox just not chrome... I will start a new question.
ian