views:

12293

answers:

2

Dear all, I have jquery that, i have called an ajax function file.php , that has some fields like Milk , Will I assign into again JQuery function, If so how to do It?.I attached the sample file

<html>
<head>
<LINK REL=StyleSheet HREF="examples.css" TITLE="Contemporary" TYPE="text/css">
<script src="jquery-1.2.6.js" type="text/javascript"></script>
<script src="jquery-impromptu.1.6.js" type="text/javascript"></script>
<script>

$(document).ready(function(){

$.ajax({
     type:"GET",
     url:"file.php",
     data:id,
     success:function(){
       var txt=id;        
       $.prompt( txt,{ opacity: 0.2 });
    },
     error:function(){
     window.location("ERRoR");
    } 
 });
});
</script>
<body>
</body>
</html>
+8  A: 

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 in the Jquery docs

Athena
A: 

try this code , and not $.ajax, $.ajax is more global function.

$.get(url,requestData,function(data){
//callback function
alert(data);
});
Moran
There's nothing 'more global' about `$.ajax`, `$.get` is simply a wrapper around `$.ajax`.
thenduks