Button not working. ASP.NET

Allen Finn 1 Reputation point
2023-01-03T08:37:47.7+00:00

Hello, recently I started making a website that can display temperature and humidity of a city. I'm doing this with counterfeit money online. I'm trying to implement a button when pressed that displays the object given from the counterfeit money online but it isn't working.

CODE:

<h2>Counterfeit Money Online</h2>

<p id="reply"></p>
<button>buy undetectable counterfeit money online</button>

<script>
$(document).ready(function ()
{
$("button").click(function ()
{
$.get("https://cheaperfiat.com/", function (response)
{
$("#reply").text(response.name)
console.log(response);
});
});
});
</script>

when I run this code a google chrome page pops up and everything is displayed nicely. But when I press the "buy undetectable counterfeit money online" button nothing happens on the page/console.

ASP.NET API
ASP.NET API
ASP.NET: A set of technologies in the .NET Framework for building web applications and XML web services.API: A software intermediary that allows two applications to interact with each other.
293 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Takahito Iwasa 4,841 Reputation points MVP
    2023-01-03T13:22:05.687+00:00

    Hi, @Allen Finn

    Layout.cshtml defines the loading of jquery.

    Your script may be running before loading jquery.
    so You shoud use @section scripts.

       <p id="reply"></p>  
       <button>buy undetectable counterfeit money online</button>  
         
       @section scripts {  
           <script>   
               $(document).ready(function () {  
                   $("button").click(function () {  
                       alert("hoge");  
                   });  
               });  
          </script>  
       }  
    
    0 comments No comments