0

Possible Duplicate:
Could not complete the operation due to error 80020101. IE

I'm facing a little problem with my jQuery code.

I have a first page with some fields like : [Code 1] [Code 2] [Code 3]

The user type something in one of the input, I get the result that I load in another page with .load method. Here's the code :

$(function() {
    $("#code_cip").autocomplete({
            source: tab,
            minLength: 6,
            delay: 1000,
            select: function(event, ui) {
                        var selectedObj = ui.item;
                        $("#code_cip_ind").val(selectedObj.value);
                        $("#test").load("test.php?id="+selectedObj.value);
            }
        });
    });

This, works great. It correctly load the "test.php" page with the good values. BUT... In the test.php page I have a form, and I try to fill it like this :

test.php :

<?php
    $gest_medecin = new gest_medecin($db);
    $medecin = $gest_medecin->returnValues();
    $adresse = $medecin->Adresse;
    echo $adresse // This, output the good value of the attribut
?>
<script>
    adresse = <?php echo $adresse;?>;
    alert(adresse);
    $("#adresse").val(adresse);
</script>
<input name="adresse" id="adresse" type="text" />

The problem is : When I try to alert the "adresse" var, or use it with my .val method, I get the error 80020101 in IE, and in Firefox, nothing is happening...

I tried to fill the variable with some test string like this :

adresse = <?php echo "123456" ?>

And that works great... As mentioned I checked that the $medecin->Adresse was correct with my echo and it is. It contains something like "word1 word2"

I really have no clue why my code isn't working...

Any help ?

Community
  • 1
  • 1
Yanis Boucherit
  • 694
  • 3
  • 8
  • 16

1 Answers1

1

Always look at the final result to spot the error.

You are missing quotes around

    adresse = "<?php echo $adresse;?>";

strings always need quotes.

it worked with 123456 because that is an integer value that needs no quotes.

Firefox will tell you this in its error console with a better error message.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • Oh gosh... I really thank you for your answer. After some coding nights, things are not so obvious for me apparently... Thanks a lot ! (I'll accept your answer in 10 minutes :) ) – Yanis Boucherit Oct 31 '12 at 08:41