Posts

Showing posts with the label asynchronous

Javascript - TypeError: x is not a function at done

Javascript - TypeError: x is not a function at done I am building my own browserside javascript sdk, using webpack and node. I have built a async/await document function, which simply submits a document to an api. This function could be called twice in the browser (if there is a second image) However on the second document function call i get the following error. TypeError: hsp.document is not a function at done index.html <script> hsp = new HSP(); // function called on button click async function done() { try { const doc = await hsp.document(transaction, token, url, this.frontBase64); console.log(doc); // If second image, submit it also. if(this.backBase64) { const doc = await hsp.document(transaction, token, url, this.backBase64); } } catch (er) { console.log(er); } } </script> sdk.js async document(transaction, token, url, doc) { try { this.document = await this.api.submit...

ajax keypress function is not working and the ActionResult parameter is not receiving any value

ajax keypress function is not working and the ActionResult parameter is not receiving any value I want to change(calculate) a textboxs' value on ajax keypress event but the controller ActionResult is not receiving any value to calculate(receiving null) <script> $('#TotDiscnt').keypress(function () { //var data = $('#totDiscnt').val(); $.ajax({ type: 'Post', url: '/Whatever/Discount', data: $('#totDiscnt').val(), success: function (response) { $('#TotPurAmt').val(response); } }); }); </script> On controller public ActionResult Discount(string text) { // calculation return Json(sum, JsonRequestBehavior.AllowGet); I tried as data: { text: request.term }, while i do that the the ajax call is not calling the controller method.And one more thing how can i send two double value as a parameter t...

How to delay a function returning a value before response from database? [duplicate]

How to delay a function returning a value before response from database? [duplicate] This question already has an answer here: I have a function which modifies a variable as per response from database. function f () { let x = { }; redis.get ("key1").then ( value => x.prop1 = value); redis.get ("key2").then ( value => x.prop2 = value); return x; } This is my code roughly. It is actually in a for loop, using node-redis. I have multiple calls to Redis. I add the data from Redis to a new object and return the object. PROBLEM: function f () is returning an empty object every time I call it. f () How do I wait for all Redis promises to resolve before returning the object? This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. 1 Answer 1 In your code, you are not waiting f...

Asynchronous WebService Approach (JAVA CXF)

Asynchronous WebService Approach (JAVA CXF) I planning to create a JAVA asynchronous webservice using CXF. This is my understanding so far: In order to create async webservice via best practice, it need to be in such way: Server: create an messanging queue like ActiveMQ, grab the webservice request to put into an inbound queue and respond with an acknowledgement synchronously process the inbound queue via listener on queue send response message back to client (via long polling from client) Client: send request to server received acknowledgement message send long polling to server until it received response from server How do I achieve it if I would like to use Callback approach instead of polling approach? Please feel free to comment or feedback. Besides, which Asynchronous Invocation Model approach (Polling or Callback) is better if the webservice server communicate with many clients at one time? – obl0702 Jul 1 at 4:30 ...

Socket BeginEnd operations and pinned buffers in .NET 4.6

Socket BeginEnd operations and pinned buffers in .NET 4.6 According to Performance Improves in .NET 4.6 and this answer, Is it possible to get OutOfMemoryException while using async socket APIs in .NET 4.6 ? The answer is yes. A system can only handle certain load, and you should scale it up when larger load is expected. There are other optimization approaches (hidden in the words of that Stack Overflow thread as well). – Lex Li Jun 30 at 15:00 By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.