Hey guys I'm new here I have a question and i have been searching everywhere, I'm trying to build a Visualforce Page that when I'm inserting a text like "To" it will generate a url like "http://www.israelpost.co.il/zip_data.nsf/CreateLocationsforAutocomplete?OpenAgent&callback=jsonp1374348764727&StartsWith="+"Tu" and will get the locations from the Json format and give the result in a drop down like Tulsa Tulsan and so on. basically all the city's that start with "Tu" the site is the post office so they have all the info then in Json format. if you what to take a look(it's in Hebrew) the full result is

jsonp1374348764727({"locations": [ {"n":"תל אביב - יפו"},{"n":"תל מונד"},{"n":"תל השומר"},{"n":"תל יוסף"},{"n":"תל יצחק"},{"n":"מחנה תל נוף"},{"n":"תל עדשים"},{"n":"תל קציר"},{"n":"תל שבע"},{"n":"תל תאומים"},{"n":"תלם"},{"n":"תלמי אליהו"},{"n":"תלמי אלעזר"},{"n":"תלמי ביל\"ו"},{"n":"תלמי יוסף"},{"n":"תלמי יחיאל"},{"n":"תלמי יפה"},{"n":"תלמים"}]});

the link:


all help will be much appreciated


This JSONP technique is primarily for calls from the browser. In your example, if you are making the call from the browser, you need to define a function to process the returned data. Usually you would register that function with the calling code but I guess you could wire it together yourself:

function jsonp1374348764727(locations) {
     for (var i = 0; i < locations.length; i++) {
         var location = locations[i];
         var value = location.n;

If you are making this call from Apex, and JSONP can't be turned off from that endpoint (check the documentation), then AFAIK you are stuck with stripping off the JavaScript function from the response by removing jsonp1374348764727( from the beginning and ); from the end. You can then feed the JSON string into the Apex JSON methods such as JSON.deserializeUntyped. Google for examples - there are plenty.

  • thanks for the answer, how do i get the field to build the url that i need i mean when the user is typing the first 2 letters the url is build and then get the info from the json and return it in the drop down on the fly so they can auto complete the city name streets and so on – Elia Nov 29 '16 at 9:30
  • @Elia I'd look for a 3rd party JavaScript library such as jqueryui.com/autocomplete - Google for something that meets your needs. – Keith C Dec 1 '16 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.