1

I have a PHP page that returns a piece of HTML to set the values of a menu.

while($employee = mysql_fetch_array($query))
        {
            $employee_menu = $employee_menu . '<option value="'.$employee['id'].'">'.$employee['first'].' '.$employee['last'].'</option>';
        }

        echo json_encode ($employee_menu);

Then update it with jquery like this:

$.get('http://www.sharingizcaring.com/schedule/menutest.php', { job: $('#job').val() },      
        function(data) 
        {

          $("#employee").html( data );

         });

For some reason the closing tags are being turned into </option> and thus displaying as either:

First Last </option> First Last >/option>

In the menu (Chrome) or as one line: First Last </option> First Last </option> (Firefox)

Is there something I need to do to the html besides json_encode before I pass it back or should I be returning an array and then creating the with jquery?

1 Answer 1

1

I don't get why you are json encoding the string you are sending to the client, just return the HTML string and update your element, i.e.: echo $employee_menu; and it should work fine.

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

Comments

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.