How to post the data in php using ajax??

Hey guys,

Once i got a situation to use iframe where i need to post the data of an employee in the same page using iframe(display all details of that employee). I couldn’t understand how to proceed..but i came to know that using ajax we can do that..

here is the scenario:

I need to click on a employee so that an iframe will open with his details..if i click another employee name then second employee details should be displayed in same iframe.

echo”<a href=’javascript:void(0);’ role=’button’  class=’empclick’ alt='”.$role[$i].”‘ onclick=’getElementValue(“.$role[$i].”,”.$Empid[$i].”,”. $status[$i].”)’>”;/*echo $role[$i];*/ echo $name[$i]; echo”</a>”;

Function:

function getElementValue(role,id,status)
{
//alert(role);

$.ajax({
type: “POST”,
url: “http://localhost:82/projectname/controllername/AssiningSession/”+ role+”/”+id+”/”+status ,
data: { value: role }
}).done(function( msg ) {
// alert( “Data Saved: ” + msg );
$(“#empcont”).attr(“src”,”iframeperffact”);
});
}

This helped me alot..hope it helps you too 🙂

Advertisements