Wednesday, 15 September 2010

javascript - json clone data to alphanumeric -



javascript - json clone data to alphanumeric -

loading json info , presenting phone number working fine calling external function info cutting part of number

the next json code:

$.ajax({ url: url, type: "get", data: {no: val }, datatype: "json", cache: false, error: function () { alert('error'); } , onfailure: function () { alert('fail'); } , success: function(result) { $.each(result.sites,function(index,dat){ var site_phone='<a href="#" onclick="dialto('+dat.telephone+')"><img src="phone.png" alt="dial" /></a>' $("#phone").append( '<div style=" height:50px;width:400px;direction:ltr;">'+ site_phone+ '<h2>'+dat.telephone+'</h2>'+ '</div>' ); }); } }) function dialto(telephone) { alert(telephone); window.open('tel:'+telephone+'', '_system'); }

dat.telephone presenting right number 077-123456 alert(telephone) presenting -123456

any idea?

try

var site_phone='<a href="#" onclick="dialto(\''+dat.telephone+'\')"><img src="phone.png" alt="dial" /></a>'

notice \' basicly how need send numper whole way renders 077-123456

javascript json

No comments:

Post a Comment