Search code examples
titaniumtitanium-mobiletitanium-alloy

How to create a request string with passing different values in Titanium?


I am creating a URL-String like this:

URLString = %@sale-ws/lots/sales?yardNumber=%@&saleFromDate=%@&range=%@&saleToDate=%@&pageSize=%@&pageNo=%@&sortBy=%@&sortType=%@&filterStartYear=%@&filterEndYear=%@&filterMake=%@&filterModel=%@&filterLocationId=%@&filterLane=%@&filterSellerId=%@&searchInSearchString=%@

So in Titanium i want to pass the values dynamically into a given string. I tried this one but did not get a proper response.

var urlParameterStringNew
=String.format(URLString,Alloy.Globals.SERVER_URL,"","","","","","","","","","","","","","","","");

Solution

  • First change , i have to create my URL like this

    URLString = "%ssale-ws/lots/sales?yardNumber=%s&saleFromDate=%s&range=%s&saleToDate=%s&pageSize=%s&pageNo=%s&sortBy=%s&sortType=%s&filterStartYear=%s&filterEndYear=%s&filterMake=%s&filterModel=%s&filterLocationId=%s&filterLane=%s&filterSellerId=%s&searchInSearchString=%s",
    

    Then i can simply to replace the value of %s with any other value like this

    var finalRequestString = String.format(URLString),Alloy.Globals.SERVER_URL,"","","","","","","","","","","","","","","","");