You need to sign in to do that
Don't have an account?
ButuzGOL
VisualForce Ajax to Apex using jQuery
How can make ajax request using jQuery in VisulForce to Apex ?
Example
$.ajax({
type :"POST",
url :'Apex-url',
dataType :"json",
success:function(data){
alert( data );
},
error :function(){
alert("Sorry, The requested property could not be found.");
}
});
Hi,
You cannot invoke the Apex code using JQuery Ajax request. For this use Javascript Remoting.
If you want to invoke other VF page :
Lets say your Apex page name is "Test2" and you are calling it from Custom VF page itself. then
In above code, it assumed that the Datatype of page is JSON.
Read below article to set the output format of visualforce page as JSON :
http://shivasoft.in/blog/salesforce/json-output-in-visualforce/
Thanks for answer
So I have such request to apex page
$.ajax({
type :"POST",
url :'Test2',
dataType :"json",
data: {"one": "1", "two": 2},
success:function(data){
alert( data );
},
error :function(){
alert("Sorry, The requested property could not be found.");
}
});
How can I get POST vars in apex -> data: {"one": "1", "two": 2}, ?