callback

ASP.NET Client to Server communication

懵懂的女人 提交于 2020-01-13 11:02:22
问题 Can you help me make sense of all the different ways to communicate from browser to client in ASP.NET? I have made this a community wiki so feel free to edit my post to improve it. Specifically, I'm trying to understand in which scenario to use each one by listing how each works. I'm a little fuzzy on UpdatePanel vs CallBack (with ViewState): I know UpdatePanel always returns HTML while CallBack can return JSON. Any other major differences? ...and CallBack (without ViewState) vs WebMethod.

php - convert a method to a closure

百般思念 提交于 2020-01-13 10:34:26
问题 I want to know is there any way to convert a method to a closure type in php? class myClass{ public function myMethod($param){ echo $param; } public function myOtherMethod(Closure $param){ // do somthing here ... } } $obj = new myClass(); $obj->myOtherMethod( (closure) '$obj->myMethod' ); this is just for example but i cant use callable and then use [$obj,'myMethod'] my class is very complicated and i cant change anything just for a closure type. so i need to convert a method to a closure. is

jQuery callback not waiting on fadeOut

这一生的挚爱 提交于 2020-01-13 09:50:10
问题 It seems to me the following code should produce these results: mademoiselle demoiselle mesdemoiselles Instead, as "ma" fades out, "mes" fades in making the sequence: mademoiselle madesdemoiselles mesdemoiselles The code: <span class="remove">ma</span><span class="add">mes</span>demoiselle<span class="add">s</span> $(document).ready(function() { $(".remove").fadeOut(4000,function(){ $(".add").fadeIn(5000); }); }); Edit: I found an empty span that if I remove makes the bug go away: <span class

Understanding JavaScript's single-threaded nature

不羁的心 提交于 2020-01-13 09:34:20
问题 I've been reading John Resig's "Secrets of a JavaScript Ninja" and it explains that JavaScript is single-threaded. However, I tried testing this and I'm not sure what to take away from here: // executing this in browser (function () { // throw something into event queue setTimeout(function () { alert("This will be called back after 1 second."); }, 1000); // arbitrary loop to take up some time for (var i = 0; i < 10000; i += 1) { console.log(i); } })(); Maybe I'm not understanding exactly what

Passing C++/CLI Class Method as C function pointer

旧巷老猫 提交于 2020-01-13 07:55:09
问题 I have a third-party C library that provides this header: //CLibrary.h #include <Windows.h> #include <process.h> typedef void (WINAPI *CLibEventCallback)(int event, void *data); __declspec(dllexport) bool CLibStart (CLibEventCallback callback, void *data); // CLibrary.c -- sample implementation static CLibEventCallback cb; void _cdecl DoWork (void *ptr) { for (int i = 0; i < 10; ++i) { cb (i*i, ptr); Sleep (500); } } __declspec(dllexport) bool CLibStart (CLibEventCallback callback, void *data

Passing C++/CLI Class Method as C function pointer

风格不统一 提交于 2020-01-13 07:55:07
问题 I have a third-party C library that provides this header: //CLibrary.h #include <Windows.h> #include <process.h> typedef void (WINAPI *CLibEventCallback)(int event, void *data); __declspec(dllexport) bool CLibStart (CLibEventCallback callback, void *data); // CLibrary.c -- sample implementation static CLibEventCallback cb; void _cdecl DoWork (void *ptr) { for (int i = 0; i < 10; ++i) { cb (i*i, ptr); Sleep (500); } } __declspec(dllexport) bool CLibStart (CLibEventCallback callback, void *data

$.when.done callback isn't working

别说谁变了你拦得住时间么 提交于 2020-01-13 06:37:07
问题 The following code has a bad syntax error. Probably because I'm using 'for' or something. $.when( for (var i=0; i < 5; i++) { $.getScript( "'" + someArr[i].fileName + ".js'"); } $.Deferred(function( deferred ) { $( deferred.resolve ); }) ).done(function() { alert("done"); }); I'm trying to call couple of scripts and then when trey are all loaded I want to an alert to show. 回答1: A commented (but untested) solution with the changes is below // When takes a promise (or list of promises), not a

Android之线程回掉更新ui

折月煮酒 提交于 2020-01-13 02:42:29
一:工作线程中的回掉更新UI public class MainActivity extends AppCompatActivity { private int i; private Callback mCallback; private TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView = (TextView) findViewById(R.id.text); mCallback = new Callback() { @Override public void callback(int i) { textView.setText("i"); } }; doWorkAsNewThread(5000,mCallback); } /** * 开启工作线程 * @param delayMs 延时,以便对比 * @param callback 回掉,更新Ui */ private void doWorkAsNewThread(final long delayMs, final Callback callback

How to pass $(this) in success callback of $.ajax

試著忘記壹切 提交于 2020-01-12 18:37:19
问题 I have seen a few different examples of accessing $(this) is the success callback of ajax but none give me the answer I want - they all access $(this) within the ajax function, I want to pass $(this) to a separate function. So if there are 2 textboxes that need to be validated $("#tb1").focusout(function(){ $.ajax({ type:'POST', url: 'validURL', data: {various_parameters}, contentType: 'application/json; charset=utf-8', dataType:'json', success: function(data){ validInput(data, $(this)); },

How to pass $(this) in success callback of $.ajax

╄→гoц情女王★ 提交于 2020-01-12 18:35:09
问题 I have seen a few different examples of accessing $(this) is the success callback of ajax but none give me the answer I want - they all access $(this) within the ajax function, I want to pass $(this) to a separate function. So if there are 2 textboxes that need to be validated $("#tb1").focusout(function(){ $.ajax({ type:'POST', url: 'validURL', data: {various_parameters}, contentType: 'application/json; charset=utf-8', dataType:'json', success: function(data){ validInput(data, $(this)); },