Good

<script type="text/javascript"> $(document).ready(function(){ //жмякнем по div $(".mydiv1").click(function(){ //возьмем какие ни будь данные var param2 = $(".mydiv2").val(); var param3 = $(".mydiv3").val(); //пошлем ajax запрос $.ajax({ url:"page.php", type:"POST", cache:true, data: { param2: param2, param3: param3 }, success: function(html){ $(".mydiv4").html(html); } }) }); }); </script> 

Actually there is such a thing, angularjs. Everything is cool, but I don’t understand how to make ajax request on it similar to what I wrote above?

Ps so that he wrote no problems

  • $http.post(...).then(function(html){...}) - Yaant
  • Mm .. can I have a detailed example? just after reading the help on the angular, my question arose - gforce

1 answer 1

Like that

 $http({ method: 'POST', data: { param2: param2, param3: param3 }, url: '/page.php' }).then(function successCallback(html) { $(".mydiv4").html(html); }, function errorCallback(response) { }); 
  • Here is the full documentation docs.angularjs.org/api/ng/service/$http - Red Woolf
  • As an option. $http.post('/page.php', { param2: param2, param3: param3 }).success(function(response){ $(".mydiv4").html(html); }).error(function(){ }); - Petr Chalov
  • The example is gorgeous, except that in my specific click on diva, i.e. page code can be written separately from scripts, in an angular I don’t understand how to do it yet - gforce
  • To be honest, agular I don’t know at all, but on a pinch, you can use regular js - Red Woolf