0

jQuery(function($) {
  $.ajax({ 
   url: 'proxy.php?url=http://school.egg-one.com/ws/player/full-profile/player_id/17353',
   contentType: "application/json; charset=windows-1252",
         dataType: "json",
         success: function(content) {
              $('#mycontent').html("" + $('#mainbuy').html() + "");    
   },
   /* Error */
      error: function(xhr, status, error){
              alert("No Json" + xhr.status);
      },
   
        
  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

                    <div id="mainbuy" style="display:none;">
                    <div class="coachbtn"><div class="dropup"><div id="buybtn"> 
                      <select class="selectpicker" data-style="btn-primary" id="pickhour" name="pickhour">
          <option value="1">1H</option>
          <option value="2" selected>2H</option>
          <option value="3">3H</option>
        <option value="4">4H</option>
          </select> 
                       </div></div></div>
                       <div class="coachbtn2"><div id="buybtn2">
                         <a id="egglink" class="button button-large" style="width: 260px">Reserver</a>
                       </div></div>
                       <script type="text/javascript">
        $(document).ready(function(){
                    $('#pickhour').change(function(){
            pickhour1 = $(this).val();
                 $("#egglink").attr("href", "http://school.egg-one.com/private-lesson/program-choice/program_choice/" + pickhour1 + "/player_id/457857");
      });
       }); 
                </script>
                    </div>
<a href="#mycontent"></a>

The HTML part define a select dropbox and a button, they got ID "pickhour" for the select and "egglink" for the button. My script in the parent div of all of these divs (im trying some tricks with css.. i dont think my problem is about that) should add the select option value to my link then set it as HREF for my button. Since I call the div "mainbuy" (which contain selectbox + button + script) in an Ajax request (you can see $('#mainbuy').html()), the content is show but the script has absolutely no effect.. I really hope someone will have a way to fix that, or a working alternative..

Thanks you in advance for answers

Anarz
  • 25
  • 7
  • http://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements – Arun P Johny Mar 13 '15 at 03:46
  • did you try checking the network tab in the web developer of your browser? what does it state when you place the ajax call! usually there should be an entry for your ajax call with headers,request and response.! check what is the response. – Imesh Chandrasiri Mar 13 '15 at 03:47
  • Its not about the response, I delete the values i get from the json before copying here, they works fine, I get the reponse and can manage it like i want, it really about my function which works on my home page but dont work when i call her with $('#mycontent').html("" + $('#mainbuy').html() + ""); I use fancybox to show it : – Anarz Mar 13 '15 at 03:50

0 Answers0