Between the script tags, you need to make it so that the data is output (data) ... If you connect separately, then everything works, but I need to have ALL code in between ONE script tags ... Tell me why it doesn't work or HOW I do, so that all the code worked between the same script tags

<div id="placeholder"></div> <!--здесь НЕ выводит --> <script src="http://code.jquery.com/jquery-1.7.1.min.js"> var data={"firstName":"Ray"}; document.getElementById("placeholder").innerHTML=data.firstName; </script> <div id="placeholder"></div> <!-- и здесь НЕ выводит --> 

The code below is working, but does NOT meet the specified requirements.

 <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script> var data={"firstName":"Ray"}; document.getElementById("placeholder").innerText=data.firstName; </script> <div id="placeholder"></div> 
  • one
    Why minus? If you do not know the answer to this question, then you need to minus the question immediately? I wrote this question because it is relevant at the moment for me and an extraordinary approach is needed in its solution ... - Alexander
  • one
    I KNOW that it is impossible !!!! but it is NECESSARY !!!! Thank you for your attention, it looks like your creative is only enough to put minuses !!!! - Alexander
  • and what are you putting minuses? Have you never done UNUSUAL test tasks for IT companies? - Alexander

3 answers 3

Because you can not turn on the 1 script and jquery tag and execute the code.

 <div id="placeholder"></div> <!--здесь НЕ выводит --> <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script> <script> var data={"firstName":"Ray"}; document.getElementById("placeholder").innerText=data.firstName; </script> <div id="placeholder"></div> <!-- и здесь НЕ выводит --> 

  • one
    I did not fully understand what the user meant by “If separately connected” - N. Turshiev
  • @Nazar Kalityuk, I’m therefore asking HOW to make me between some script tags ... read carefully the question - there I said that if you connect jquery separately, it works - Alexander
  • 2
    @Alexandr Then paste the entire contents of the jquery-1.7.1.min.js file into the script body, and then write your code. - Igor Lut
  • @IgorLut, thanks for the hint !!! The ONLY suitable solution! Thanks! - Alexander

Good evening, because you are using jQuery, you can use a different syntax

 $("#placeholder").html(data.firstName) 

    I found a solution ..... stupid, but it works, and most importantly satisfies the requirements of the question:

     <script src="http://code.jquery.com/jquery-1.7.1.min.js"> <?php echo '</Script>'; ?> <?php echo '<script>'; ?> var data={"firstName":"Ray"}; document.getElementById("placeholder").innerText=data.firstName; </script> <div id="placeholder"></div> 
    • one
      and what is the meaning of it? This is equivalent to simply creating two script tags, as everyone advised you. Open the page in your browser and see just two script tags - Igor Lut
    • @Igor Lut, I wrote in the question what exactly is needed between the same tags, and what is between me and so it works ... but they started minusing me ... the task was given to me, the condition is that ALL content was between the tags alone It’s as if no one who put a minus has ever done such tasks ... - Alexander
    • one
      <?php echo '</script>'; ?> <?php echo '</script>'; ?> just turn into </script> . This is ABSOLUTELY too, if you would just insert </script> . In the end, you have two script tags, not one - Igor Lut
    • @Igor Lut I know, so it’s necessary for the browser to read it SO !!! task, so that the script is between some script tags and it can be pasted anywhere, so that it is independent of anything! - Alexander
    • one
      You probably do not understand, but your answer turns into the answer that Nazar Kalituk gave you. There is no difference in them. Well, you know better, meaningless argument. - Igor Lut