views:

219

answers:

0

hi. i am developing web app in iphone using dashcode 3.0 and i am completely new for it. I have one problem. I have created one search button for searching particular city which inserted in search Field. List items which having cities bounded using binding datasource which is running successfully but when i want to search particular city the list wont be reloaded. my code is as below. Someone can help me then i am so grateful to him. Thanks in advance.

function search_destination_click(event)

{
// Insert Code Here
// Values you provide

var xmlRequest = new XMLHttpRequest();

var searchFieldValue = document.getElementById('search3'); // replace with ID of search field

// Search field code

var searchFieldValue = searchFieldValue.value;

alert(searchFieldValue);

// Values you provide

// The feed to fetch

var feedURL = "http://webservice/getdestination/" + searchFieldValue ;//+ "&resultformat=json";

var onloadHandler = function(){

alert(xmlRequest.status);

if(xmlRequest.status == 200) {

alert(xmlRequest.responseText);

DC.dataModel.dataSource.content = xmlRequest.responseText; 




/*var listController = {

_rowData:[
"item1","item2","item3"
],

numberOfRows: function() {
return this._rowData.length;
},

prepareRow: function(rowElement, rowIndex, templateElements) {
if (templateElements.label7) {
templateElements.label7.innerText = this._rowData[rowIndex];
}
}
}*/

DC.dataModel.list7.setContent = xmlRequest.responseText;

// alert(DC.dataModel.list7.setContent);

// list7.reloadData();

document.getElementById('list7').object.reloadData();

} 

else {
alert("Error fetching data:HTTP status " + xmlRequest.status);
}
}
xmlRequest.onload = onloadHandler;

xmlRequest.open("GET", feedURL);

xmlRequest.setRequestHeader("Cache-Control", "no-cache");

xmlRequest.send(null);

}

I am using XML data for fetching details. XML data can be fetched by this code but the list will not be reloaded.