jQuery Ajax: return value to caller?

前端 未结 2 659

I have some jQuery code. I have called an Ajax function file, file.php, that has some fields, like:

Milk

        
相关标签:
2条回答
  • 2020-12-11 23:58

    The success function takes a parameter, which contains the fetched data. So in your example:

    $(document).ready(
        function(){ $.ajax({
           type:"GET",
           url:"file.php",
           data:id,
           success:function(txt){
              $.prompt( txt,{ opacity: 0.2 });
           },
           // ... more ...
        }
    });
    

    More examples are in the jQuery documentation.

    0 讨论(0)
  • 2020-12-12 00:05
    jQuery.ajax({
         type:"POST",
         url:"file.php",
         data:"id1="+val1+"&id2="+val2,
         success:function(data){
           jQuery("#div_id").html(data);
        }
    
    0 讨论(0)
提交回复
热议问题