I have upated the question now. Below is the code which i stored in the external js file.
$js ='
var i=1;
var siteUrl = "http://'.$_SERVER['SERVER_NAME'].'";
$jd = jQuery.noConflict();
function dialog(urlvalue){
$jd( "#dialog" ).dialog();
alert("+urlvalue+");
}
$jd(document).ready(function(){
var id = $jd(".product");
id.each(function(index,element){
//var productUrl = $jd(".product").attr("href");
var productUrl = $jd("a:first-child ", this).attr("href");
if(productUrl != undefined){
//console.log(productUrl);
productUrl = siteUrl + productUrl ;
//$jd(this).addClass("item-" + i);
//console.log("checking"+index);
$jd(".vm-product-media-container").addClass("view view-first");
//console.log($jd(".js-recalculate input[name=pid]").val());
$jd(".view-first", this).append("<button onclick=\"dialog("+productUrl+")\" class=sdlc_quick> Quick View</button>");
//console.log(productUrl);
}
});
})';
$doc->addScriptDeclaration($js);
I am getting an error missing argument when i clicked on the button quick view. Below is the code:-
$jd(".view-first", this).append("<button onclick=\"dialog("'+productUrl+'")\" class=sdlc_quick> Quick View</button>");