Purpose of Jquery in php

Asked

Viewed 51 times

0

In my graduation, I studied about RIA - rich internet and did not fix very well the concept of using the jquery(JS) library in web languages. Could someone enlighten me? Thank you!

  • 2

    PHP is a language backend, that is, runs on the server and aims to "mount" the HTML page and send to the client (usually your browser). While jQuery is a JS library that runs on the client. These are completely parallel subjects, because the two have no relation, jQuery does not know (and does not need to know) who assembled the HTML or if the HTML is static.

  • Well, researching now the argument was similar, with some differences in which Js using the Jquery library made requests at runtime (real) so that the web application would look similar to a desktop not needing to reload the php page every time..

  • 1

    There you are talking about AJAX which, briefly, is a way to make a request to a server asynchronously using JS without having to reload the page. But still, this server can be anything, not necessarily PHP.

  • Thanks for the clarification.

  • 2

    Just to clarify, jQuery solved a problem in its time and that today is not so evident, the incompatibility of code between browsers. Of course, jQuery is still useful, but its main features are already native to modern browsers and have decent compatibility.

1 answer

2


The JQuery has no purpose especially for PHP, can be worked with other languages in the same way.

It’s a library JavaScript resource-rich for rapid page and document development HTML it is possible to manipulate components, images, animations, requests AJAX among others being a API easy to learn and functional in multiple browsers.

Examples JQuery:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<p>Vai sumir hein</p>
<button onclick='$("p").hide()'>Esconder</button>

In the above code you can easily select a component and hide it.

Another example is the assignment of an event to an element:

$('#ID_Elemento').on('click', function (){ 
  alert('Evento onClick() funcionando!')
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button id="ID_Elemento">Clique</button>

You can get more examples and information on the website itself Jquery

Browser other questions tagged

You are not signed in. Login or sign up in order to post.