Skip to main content

Posts

Showing posts with the label function

function* in JavaScript

In this page I found a new JavaScript function type: // NOTE: "function*" is not supported yet in Firefox. // Remove the asterisk in order for this code to work in Firefox 13 function* fibonacci() { // !!! this is the interesting line !!! let [prev, curr] = [0, 1]; for (;;) { [prev, curr] = [curr, prev + curr]; yield curr; } }

PHP pass function as param then call the function?

I need to pass a function as a parameter to another function and then call the passed function from withing the function...This is probably easier for me to explain in code..I basically want to do something like this: function ($functionToBeCalled) { call($functionToBeCalled,additional_params); } Is there a way to do that.. I am using PHP 4.3.9 Thanks! Source: Tips4all

Passing parameters to a JQuery function

I'm creating HTML with a loop that has a column for Action. That column is a Hyperlink that when the user clicks calls a JavaScript function and passes the parameters... example: <a href="#" OnClick="DoAction(1,'Jose');" > Click </a> <a href="#" OnClick="DoAction(2,'Juan');" > Click </a> <a href="#" OnClick="DoAction(3,'Pedro');" > Click </a> ... <a href="#" OnClick="DoAction(n,'xxx');" > Click </a> I want that function to call an Ajax jQuery function with the correct parameters. Any help? Source: Tips4all

this.function is not a function error, but function exists

I have some code to get calendar events and display them. The display is only updated if the events have changed, since the last call. var calendar = { events = null, display_calendar_events : function (data) { // Some display stuff... }, get_events: function() { // Get messages for calendar $.getJSON("/ajax/get-events/", function(json){ var new_events = json.data; // If events haven't changed, do nothing if (this.events === new_events) { return true; } // Events have changed. // Save new events this.events = new_events; // Display new events this.display_calendar_events(json); }); }, } I call this with: calendar.get_queued_events(); The problem is, I'm getting the error "this.display_calendar_events is not a function" (last line of code). But if I change this line to: calendar.d

javascript function not returning correct value

I have this function that checks a UK postcode. The problem is that it never returns true or false - only undefined . function PostcodeAnywhere_Interactive_FindByPostcode_v1_00(Key, Postcode, UserName) { var retval; $.getJSON("https://services.postcodeanywhere.co.uk/PostcodeAnywhere/Interactive/FindByPostcode/v1.00/json3.ws?", { Key: Key, Postcode: Postcode, UserName: UserName }, function (response) { // Test for an error if (response.Items.length == 1 && typeof(response.Items[0].Error) != "undefined") { // Show the error message retval = false; } else { // Check if there were any items found if (response.Items.length == 0){ retval = false; } else { retval = true; } } }); return retval; } To me it looks like it should always return true or false , so I can't unders

PostGIS function to connect geometry LINE together?

(note: the_geom is a geometry value (TYPE: LINESTRING), in this case i random them for readability) gid | kstart | kend | ctrl_sec_no | the_geom | the_sum_geom 626 | 238 | 239 | 120802 | 123456 | NULL 638 | 249 | 250 | 120802 | 234567 | NULL 4037| 239 | 249 | 120802 | 345678 | NULL [Real Practice Description] just skip this for those who don't mind the purpose I would like to do 'this' (a set of queries from my past question, link located on the end of this post) for every row in Table B (aka. land_inventory). These two tables are related by 'ctrl_sec_no' (aka. control section number of a road) which means :: in ONE ctrl_sec_no -- 120802 (in fact, it is a road which is equivalent to 3 geometry LINESTRINGs (the_geom) connected together, from kstart 238 (start at kilometre of 238) to kend 250) [PostGIS question] the question is how to connect this 3 lines {aka gid(626,638,4037) from the table} together a