0

Hi can someone explain me this code? actually i need to write another function like this but without passing any parameter, then what should I insert in data? the code is using the parameter id in data but what if i dont have any parameter?

    server.prototype.GetSpeed=function(id){

        $.ajax(
        {url:"marks.php",
        data: {id:id},
        type:"POST",
        dataType: "json",
        success:function(data){
            //do something.
        }
        }
        );
2
Contributors
3
Replies
10
Views
4 Years
Discussion Span
Last Post by radhakrishna.p
0

hai techyworld,

if you dont have any parameter then remove the entry from the $ajax() request like as folows

 $.ajax(                       // this is also valid ajax call 
 { 
   url:"marks.php",
   type:"POST",
   dataType: "json",
   success:function(data){
    //do something.
   }
};

passsing data to the resource is not compulsarily in ajax concept (based on your requirement you need to pass those data values to the particular resource)

go through the following url it will explains different modes of $ajax() calls

http://api.jquery.com/jQuery.ajax/

let me know if you have any doubts in my clarification

happy coding

Edited by radhakrishna.p: providing for clarity on the solution

0

then will i get the value return from my php in "data" here:

success:function(data){
alert(data);
}
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.