2016-03-27 17 views
-2

Doğru yaptığımı emin değilim. Ajax 'GET' isteği için bir URL iletiyorum ve URL bazı sorgu parametrelerine sahip (? Abc = 'a'). Ancak, başarılı bir şekilde konsol.log (yanıt) yapıyorum: function (response) {console.log (response)} yanıt, abc değerini içermiyor.Başarımda başarı nedir: ajax içinde işlev (yanıt)

+2

IS söz konusu kod verebilir misiniz? Bakmak için bir kodumuz varsa cevap vermek daha kolay. –

+0

Neden ** yanıtının ** ** talebi ** parametrelerini içermesini bekliyorsunuz? –

+0

* "başarıda cevap nedir: ajax'taki işlev (yanıt)" * [Bu, dokümantasyonda mükemmel bir şekilde açıklanmıştır] (http://api.jquery.com/jQuery.ajax). –

cevap

0

Sana konsol verilerine ajax ile göstermek için bir örnek gösterecektir:

<script type="text/javascript"> 
    //this the DOM 
    $(function(){ 

     $('body').on('click', '.action_button', function() { 
      $x = { 
       key:'show', 
       values:$('.values').val() 
      }; $.post('ajax.php', $x, function(response) { 
       console.log(response); 
      }); 
     }); 

    }); 
</script> 


<?php 
    //your php file in ajax.php (another file) 
    $key = $_POST['key']; 

    switch ($key) : 
     case 'show' : 
      $values = $_POST['values']; 
      echo $values; 
     break; 
    endswitch; 
?> 

HTML BURAYA

<input type="text" class="values" placeholder="Give me some values"> 
<input type="button" class="action_button" value="Click me for show the links"> 
İlgili konular