I send the input value to another file, get the answer back and slip it into the div


chrome does not show errors, the alert shows that the variable has the value #window but nothing comes to the div ((
Surely some kind of stupid inaccuracy, I can not understand!


I have several requests, I wanted to make a function, at the same time to practice, but this construction does not work for me. well, the construction itself works ...

I don’t want to give me this JS, tell me how to make it work? I understand with the help of return; I need to translate this business into a global one, but I can’t redeem it in any way, I need to get the result back in the div ...

  • I study, I did not want to ask stupid questions, but I had to -

  $(document).ready(function() { var i_dir = 'window'; var id_dir = '#' + i_dir; //alert(id_dir); function my_dir(i_dir) { $.post( 'sys/' + i_dir + '.php', function(msg) { $(id_dir).html(msg); } ); }; }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div id="window"></div> 

  • And what php-file gives? - MAX
  • html, the request itself works! I just really want to understand js, and not just stupidly copy someone else's code without understanding ... although without understanding there are a lot of difficulties ... - Mitya To-Da-Se
  • How do you call the my_dir function? - mix
  • First, the pound sign in the URL is not transmitted directly, but as % 23 - KrasPvP
  • mix, damn, I did not sleep for a day, I completely forgot to call her)))) it all worked) thanks! what a shame))))) KrasPvP, thanks, I will know! ) although it did so - Mitya To-Da-Se

0