Prototype a Javascript framework makes life of Ajax Request as easier as ever though they are also available in Jquery but I prefer this framework infact I heard somewhere that Jquery is also based on this
All you have to do is download and include prototype.js from
http://www.prototypejs.org/
and then use the following Url
new Ajax.Request("url",
{
asynchrnous:"false";
method:post;
onSuccess: responsefunction;//(function name to which response needs to be sent)
parameters:{sum:amount,rowid:rowid},
onComplete:function(request,json){ element.hide('loader');},
onLoad:Element.show('loader')
});
function responsefunction(rsp)
{
var response =eval('(' + rsp.responseText + ')')
console.log(response)//show response in firebug
var amt=rsp.request.parameter.sum;
var name=response.Name //array which came from the json data thrown by url
}
);
//since its javascript data outputted must be json always by the url.
//rsp contains the values of all your response which comes from url
//at the url
json_encode($fetchdata);//most important to encode your data be it any file
?>
this $fetchdata comes as json in the responsefunction(rsp)
All you have to do is download and include prototype.js from
http://www.prototypejs.org/
and then use the following Url
new Ajax.Request("url",
{
asynchrnous:"false";
method:post;
onSuccess: responsefunction;//(function name to which response needs to be sent)
parameters:{sum:amount,rowid:rowid},
onComplete:function(request,json){ element.hide('loader');},
onLoad:Element.show('loader')
});
function responsefunction(rsp)
{
var response =eval('(' + rsp.responseText + ')')
console.log(response)//show response in firebug
var amt=rsp.request.parameter.sum;
var name=response.Name //array which came from the json data thrown by url
}
);
//since its javascript data outputted must be json always by the url.
//rsp contains the values of all your response which comes from url
//at the url
json_encode($fetchdata);//most important to encode your data be it any file
?>
this $fetchdata comes as json in the responsefunction(rsp)
No comments:
Post a Comment