我有以下 Jquery 电话。
$("#btnfindAddress").click(function() {
var dataString = '';
//built the data string that will be sent with ajax
dataString += 'business_name='+$('#company').val()+'&';
dataString += 'business_city='+$('#city').val()+'&';
dataString += 'business_country='+$('#country').val()+'&';
dataString += 'business_zipcode='+$('#zipcode').val();
$.ajax({
type: "GET",
url: "/locations/search",
contentType: "application/text; charset=utf-8",
data: dataString,
success: function(data){
var text_result="";
text_result="<table id=\"thetable\"><tbody>";
$.each(data,function(index,value){
text_result+="<tr>";
text_result+="<td>"+value.name+"</td>";
text_result+="<td>"+value.address+"</td>";
text_result+="<td>"+value.zipcode+"</td>";
text_result+="<td><a name="+ value.name+" address="+value.address+" city="+value.city+"href=>Select</a></td>";
text_result+="</tr>";
});
$('#locations').html(text_result);
}
});
return false;
});
它生成以下html
<a href="" angeles="" city="Los" website="null" zipcode="90007" st="" hoover="" s="" address="3303" coffee="" name="Starbucks">Select</a>
这些值按空格分隔。
应该是
<a href="" city="Los angeles" address="3303 S Hoover st" coffee="" name="Starbucks">Select</a>
我怎样才能解决这个问题 ?
谢谢