jQuery Ajax: return value to caller?

前端 未结 2 654

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.

提交回复
热议问题