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.
        }
        }
        );

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

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

success:function(data){
alert(data);
}

yeah you are right

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.