Monday, May 27, 2013

How to send or assign Jquery Variable value to php variable?

How to send or assign Jquery Variable value to php variable?

I wanted to get a img src to php variable when a user clicks it so i used jquery function to get img src when user clicks that image.Below jquery is for fetching img src
$("img").click(function() {
    var ipath = $(this).attr('src');
})
now i tried something like this to get the ipath value to php variable
$.ajax({ type:'POST', url: 'sample.php',
 dataType: 'HTML', data: dataString,
 success: function(data)
{
 }
});
});
I'm not sure about using Ajax correctly can anyone help with Ajax function to get this done? Thank you.