Search Results

Search found 1302 results on 53 pages for 'async'.

Page 37/53 | < Previous Page | 33 34 35 36 37 38 39 40 41 42 43 44  | Next Page >

  • Pattern for limiting number of simultaneous asynchronous calls

    - by hitch
    I need to retrieve multiple objects from an external system. The external system supports multiple simultaneous requests (i.e. threads), but it is possible to flood the external system - therefore I want to be able to retrieve multiple objects asynchronously, but I want to be able to throttle the number of simultaneous async requests. i.e. I need to retrieve 100 items, but don't want to be retrieving more than 25 of them at once. When each request of the 25 completes, I want to trigger another retrieval, and once they are all complete I want to return all of the results in the order they were requested (i.e. there is no point returning the results until the entire call is returned). Are there any recommended patterns for this sort of thing? Would something like this be appropriate (pseudocode, obviously)? private List<externalSystemObjects> returnedObjects = new List<externalSystemObjects>; public List<externalSystemObjects> GetObjects(List<string> ids) { int callCount = 0; int maxCallCount = 25; WaitHandle[] handles; foreach(id in itemIds to get) { if(callCount < maxCallCount) { WaitHandle handle = executeCall(id, callback); addWaitHandleToWaitArray(handle) } else { int returnedCallId = WaitHandle.WaitAny(handles); removeReturnedCallFromWaitHandles(handles); } } WaitHandle.WaitAll(handles); return returnedObjects; } public void callback(object result) { returnedObjects.Add(result); }

    Read the article

  • Facebook XFBML Like Button incompatible with FeatureLoader script?

    - by retailevolved
    Facebook gurus, I have been implementing the Facebook Like button for a number of clients lately. To enable the Like Button, the following script has to be run: <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({appId: '<?php echo Mage::helper("evlike")->getLikeConfig("ev_facebook_app_id") ?>', xfbml: true}); }; (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); </script> It seems that this is incompatible with the following include: <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript"></script> It would make sense as I believe that the FeatureLoader performs an initialization. Is this official now? I would ask in official Facebook forums but I get an error every time I attempt to do so...

    Read the article

  • Call Webservice using Javascript

    - by ajithperuva
    I am trying to call a webservice using javascript.But it shows an error like selectSingleNode() is not a method.I am trying it in mozilla firefox.Which is perfectly working in explorer when i change XMLHttpRequest to ActiveXObject.here i am adding my source code which i am tried in firefox. // Web Service functionality // Global vars var xmlDoc = null; var _serviceCallback = null; // Calls web service, web service url and parms, and callback function or null must be provided. // Callback function receives a true or false based on success of call to host function callWebService(url, callback) { _serviceCallback = callback; if(xmlDoc == null) { // xmlDoc = new XMLHttpRequest(); xmlDoc = new XMLHttpRequest(); } xmlDoc.onreadystatechange = stateChange; //callback for readystate xmlDoc.async = true; //do background processing //xmlDoc.load(url); xmlDoc.open('GET', url); xmlDoc.send(); //var doc= xmlDoc.responseXML; } // Updates readystate by callback function stateChange() { if (xmlDoc.readyState == 4) { var err = xmlDoc.parseError; var result = false; var nd; if(err.errorCode == 0) { nd = xmlDoc.selectSingleNode("//envelope/date_time"); if(nd.text != "") result = true; } // perform callback if provided if(_serviceCallback != null) _serviceCallback(result, nd == null ? "" : nd.text); } } // Callback supplied to XMLHttpRequest call function callbackTest(result, data) { obj = document.getElementById("txtOuput"); if(result) obj.value = "Success " + data; else obj.value = "Web Service Call Failed"; } Please help me...Already which kill my 8 more hours...

    Read the article

  • Browser freeze while ajax call in action

    - by kaivalya
    I have a ASP.NET Web App. I notice that while a simple ajax call(see below) is in process, web application does not respond to any action that I try on a different browser. $.ajax({ type: "GET", async: true, url: "someurl", dataType: "text", cache: false, success: function(msg){ CheckResponse(msg); } }); This happens when I open two firefox or two IE. I run the function that does the ajax call on first browser and till the response of the ajax is returned, I cannot do anything on the second browser on the same site. No breakpoints are hit on the server from the second browser till initial ajax is completed. It hangs for any click etc.. The hang on the second browser ends immediately after the ajax call is completed on the first one. This behavior is not observed if I try the same on IE and Firefox side by side. Only happen with IE & IE or FF & FF side by side Appreciate if you can help me see what I am missing here.

    Read the article

  • Rotate a feature Image in Open Layers - Javascript variable from JSON.

    - by Ozaki
    I have an open layers map. It adds and removes my "imageFeature" every 10secs or so. I have a JSON feed that gives me the rotation that I need, I have a request to get that rotation and set it as a variable of rotationv. Everything works but the fact when the image is recreated it does not update the rotation. My code is as follows: JSON request: var rotationv = (function () { rotationv = null; $.ajax({ 'async': false, 'global': true, 'url': urldefault, 'dataType': "json", 'success': function (data) { rotationv = data.rotation; } }); return rotationv })(); Creating image feature: imageFeature = new OpenLayers.Feature.Vector( new OpenLayers.Geometry.Point(mylon, mylat), { rotation: rotationv } ); The image is set in the styling elsewhere. Why does this not rotate my image? Debugging with firebug I now notice that "rotationv" is updating as per it should be. But when the point is destroyed then added again it does not apply the new rotation... Add: I realised that the "image" is applied as per the layer. So I need to figure out how to re apply the stylemap to the layer so it will trigger the "update" on the page. //redefine layer 2 so it can be updated// //test.js is just a 0.0 testref// var layer2 = new OpenLayers.Layer.GML("Layer 2", "test.js", { format: OpenLayers.Format.GeoJSON, styleMap: styleMap }); But even if I add the above into my function still no luck. Included map.addLayers([layer2]); into the function as well.

    Read the article

  • calling .ajax() from an eventHandler c# asp.ent

    - by ibininja
    Good day...! In the code behind (upload.aspx) I have an event that returns the number of bytes being streamed; and as I debug it, it works fine. I wanted to reflect the numbers returned from the eventHandler on a progress bar and this is where I got lost. I tried using jQuery's .ajax() function. this is how I implemented it: In the EventHandler in my code behind I added this code to call the .ajax() function: Page.ClientScript.RegisterStartupScript(this.GetType(), "UpdateProgress", "<script type='text/javascript'>updateProgress();</script>"); My plan is whenever the eventHandler function changes the values of bytes being streamed it calls the javascript function "updateProgress()" The .ajax() function "UpdateProgress()" is as: function updateProgress() { $.ajax({ type: "POST", url: "upload.aspx/GetData", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", async: true, success: function (msg) { $("#progressbar").progressbar("option", "value", msg.d); } }); } I made sure that the function GetData() is [System.Web.Services.WebMethod] and that it is static as well. so the workflow of what I am trying to implement is as: - Click On Upload button - The Behind code starts executing and EventHandler triggers - The EventHandler calls .ajax() function - The .ajax() function retrieves the bytes being streamed and updates progress bar. When I ran the code; all runs well except that the .ajax() is only executed when upload is finished (and progress bar also updates only when finished upload); even though I call .ajax() function every time in the eventHandler function as reflected above... What am I doing wrong? Am I thinking of this right? is there anything else I should add maybe an updatePanel or something? thank you

    Read the article

  • how to do these in visio 2007?

    - by user285825
    I am very annoyed with this software. I am unable to do many things with this software. In the book 'UML distilled' many features of UML are discussed which I am not sure how to accomplish with visio 2007. For instance, 1) I can't find the unary association. In the UML static structure under shapes panel on left, there are a lot of components like package, class, blah, blah, binary association, blah, blah, association class. But where is unary association. 2) For sequence diagram, I created a message (any of sync, async, call type message, ordinary message). The I tried to incorporate some parameter information. I went to the properties. There were a category called arguments. But selecting that shows a table where arguments are supposed to be shown. But all are diasbled. 3) For sequence diagram, there is no component delete (the big X) in the UML Sequence. 4) For class diagram, there is supposed to be a comment compartment where comments like mentioning the responsibilities are allowed using a comment prefixed with "--". But I am not sure how to accomplish them. 5) there is also supposed to be a way to indicate static properties of a class. But I am not sure how to do that in visio. 6) there is supposed to be a stereotype for class <. But in the stereotype drop down there is no stereotype. 7) where is the ball and socket component?

    Read the article

  • javascript XSL in google chrome

    - by Guy
    Hi, I'm using the following javascript code to display xml/xsl: function loadXMLDoc(fname) { var xmlDoc; // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } try { xmlDoc.async=false; xmlDoc.load(fname); return(xmlDoc); } catch(e) { try //Google Chrome { var xmlhttp = new window.XMLHttpRequest(); xmlhttp.open("GET",file,false); xmlhttp.send(null); xmlDoc = xmlhttp.responseXML.documentElement; return(xmlDoc); } catch(e) { error=e.message; } } } function displayResult() { xml=loadXMLDoc("report.xml"); xsl=loadXMLDoc("report.xsl"); // code for IE if (window.ActiveXObject) { ex=xml.transformNode(xsl); document.getElementById("example").innerHTML=ex; } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); resultDocument = xsltProcessor.transformToFragment(xml,document); document.getElementById("example").appendChild(resultDocument); } } It works find for IE and Firefox but chrome is fail in the line: document.getElementById("example").appendChild(resultDocument); Thank you for you help

    Read the article

  • passing callback function accross windows causing error with ie ...

    - by krul
    I have a problem with IE causing two errors: 1. Object doesn't support this property or method 2. Call was rejected by callee. My Intention: To call window.opener.myObject method that is going to retrieve some data using ajax and pass in callback function that live as nested function in popup window that initiated call that is going to handle response data and modify popup window html accordingly. Here is a scenario: I pull up popup window that handles some specific operation. This popup window calling window.opener.myObject method that using ajax call. I'm passing in popup window function that is going to handle response and it works with ff and safari but not with ie. Here is code sample //RELEVANT SCRIPT ON POPUP WINDOW $('#myButton').live('click', function() { var h = window.opener.myObject, p = { 'p1': 1 }; var responseHandler = function(responseObj) { //in IE we never got here if (!responseObj) { alert('Unexpected error!! No response from server'); return false; } //..handle response }; p.p1 = $('#control').val(); h.executeMethod(p, responseHandler); }); //RELEVANT SCRIPT ON WINDOW OPENER MYOBJECT try { $.ajax({ type: 'POST', async: true, url: url, data: postData, dataType: "json", contentType: 'application/x-www-form-urlencoded; charset=utf-8', success: r, // r here is reference to my responseHandler popup window function error: handleError }); } catch (ex) { alert(ex.message); } Any tips?

    Read the article

  • Strange GWT serialization exception when overiding method of serialized object

    - by Flueras Bogdan
    Hi there! I have a GWT serializable class, lets call it Foo. Foo implements IsSerializable, has primitive and serializable members as well as other transient members and a no-arg constructor. class Foo implements IsSerializable { // transient members // primitive members public Foo() {} public void bar() {} } Also a Service which handles RPC comunication. // server code public interface MyServiceImpl { public void doStuff(Foo foo); } public interface MyServiceAsync { void doStuff(Foo foo, AsyncCallback<Void> async); } How i use this: private MyServiceAsync myService = GWT.create(MyService.class); Foo foo = new Foo(); ... AsyncCallback callback = new new AsyncCallback {...}; myService.doStuff(foo, callback); In the above case the code is running, and the onSuccess() method of callback instance gets executed. But when I override the bar() method on foo instance like this: Foo foo = new Foo() { public void bar() { //do smthng different } } AsyncCallback callback = new new AsyncCallback {...}; myService.doStuff(foo, callback); I get the GWT SerializationException. Please enlighten me, because I really don't understand why.

    Read the article

  • Google Analytics Event Tracking and Variable visibility.

    - by Jeow
    Hi guys, I have added to my html page the standard latest snippet to get google analytics to work: ... ... var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-15080849-1']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = 'http://www.google-analytics.com/ga.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga); })(); Now looking at the official 'event tracking guide' google says: add a snippet such as: pageTracker._trackEvent('Videos', 'Play', 'Gone With the Wind'); my question is: where is pageTracker coming from ? is it a global object in ga.js ? but if it is, why google did not tell me that they run a risk on breaking some script... I must be missing something any help really appreciated.

    Read the article

  • How to get JSON code into MYSQL database?

    - by the_boy_za
    I've created this form with a jQuery autocomplete function. The selected brand from the autocomplete list needs to get sent to a PHP file using $.ajax function. My code doesn't seem to work but i can't find the error. I don't know why the data isn't getting inserted into MYSQL database. Here is my code: JQUERY: $(document).ready(function() { $("#autocomplete").autocomplete({ minLength: 2 }); $("#autocomplete").autocomplete({ source: ["Adidas", "Airforce", "Alpha Industries", "Asics", "Bikkemberg", "Birkenstock", "Bjorn Borg", "Brunotti", "Calvin Klein", "Cars Jeans", "Chanel", "Chasin", "Diesel", "Dior", "DKNY", "Dolce & Gabbana"] }); $("#add-brand").click(function() { var merk = $("#autocomplete").val(); $("#selected-brands").append(" <a class=\"deletemerk\" href=\"#\">" + merk + "</a>"); //Add your parameters here var param = JSON.stringify({ Brand: merk }); $.ajax({ type: "POST", async: true, url: "scripttohandlejson.php", contentType: "application/json", data: param, dataType: "json", success: function (good){ //handle success alert(good) }, failure: function (bad){ //handle any errors alert(bad) } }); return false; }); }); PHP FILE: scripttohandlejson.php <?PHP $getcontent = json_decode($json, true); $getcontent->{'Brand'}; $vraag ="INSERT INTO kijken (merk) VALUES ='$getcontent' "; $voerin = mysql_query($vraag) or die("couldnt put into db"); <?

    Read the article

  • here is my code in Jquery and Asp.net Unable to get a correct ANS as I am getting from jquery?

    - by ricky roy
    unable to get the correct Ans as i am getting from the Jquery I am using jquery.countdown.js here is my code [WebMethod] public static String GetTime() { DateTime dt = new DateTime(); dt = Convert.ToDateTime("April 9, 2010 22:38:10"); return dt.ToString("dddd, dd MMMM yyyy HH:mm:ss"); } html file <script type="text/javascript" src="Scripts/jquery-1.3.2.js"></script> <script type="text/javascript" src="Scripts/jquery.countdown.js"></script> <script type="text/javascript"> $(function() { var shortly = new Date('April 9, 2010 22:38:10'); var newTime = new Date('April 9, 2010 22:38:10'); //for loop divid /// $('#defaultCountdown').countdown({ until: shortly, onExpiry: liftOff, onTick: watchCountdown, serverSync: serverTime }); $('#div1').countdown({ until: newTime }); }); function serverTime() { var time = null; $.ajax({ type: "POST", //Page Name (in which the method should be called) and method name url: "Default.aspx/GetTime", // If you want to pass parameter or data to server side function you can try line contentType: "application/json; charset=utf-8", dataType: "json", data: "{}", async: false, //else If you don't want to pass any value to server side function leave the data to blank line below //data: "{}", success: function(msg) { //Got the response from server and render to the client time = new Date(msg.d); alert(time); }, error: function(msg) { time = new Date(); alert('1'); } }); return time; } function watchCountdown() { } function liftOff() { } </script>

    Read the article

  • Sql Exception: Error converting data type numeric to numeric

    - by Lucifer
    Hello We have a very strange issue with a database that has been moved from staging to production. The first time the database was moved it was by detaching, copying and reattaching, the second time we tried restoring from a backup of the staging. Both SQL Servers are the same version of MS SQL 2008, running on 64 bit hardware. The code accessing the database is the same build, built using the .net 2.0 framework. Here is the error message and some of the stack trace: Exception Details: System.Data.SqlClient.SqlException: Error converting data type numeric to numeric. Stack Trace: [SqlException (0x80131904): Error converting data type numeric to numeric.] System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +1953274 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4849707 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +204 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +954 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162 System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +175 System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +137 Version Information: Microsoft .NET Framework Version:2.0.50727.4200; ASP.NET Version:2.0.50727.4016

    Read the article

  • Silverlight 3 data-binding child property doesn't update

    - by sonofpirate
    I have a Silverlight control that has my root ViewModel object as it's data source. The ViewModel exposes a list of Cards as well as a SelectedCard property which is bound to a drop-down list at the top of the view. I then have a form of sorts at the bottom that displays the properties of the SelectedCard. My XAML appears as (reduced for simplicity): <StackPanel Orientation="Vertical"> <ComboBox DisplayMemberPath="Name" ItemsSource="{Binding Path=Cards}" SelectedItem="{Binding Path=SelectedCard, Mode=TwoWay}" /> <TextBlock Text="{Binding Path=SelectedCard.Name}" /> <ListBox DisplayMemberPath="Name" ItemsSource="{Binding Path=SelectedCard.PendingTransactions}" /> </StackPanel> I would expect the TextBlock and ListBox to update whenever I select a new item in the ComboBox, but this is not the case. I'm sure it has to do with the fact that the TextBlock and ListBox are actually bound to properties of the SelectedCard so it is listening for property change notifications for the properties on that object. But, I would have thought that data-binding would be smart enough to recognize that the parent object in the binding expression had changed and update the entire binding. It bears noting that the PendingTransactions property (bound to the ListBox) is lazy-loaded. So, the first time I select an item in the ComboBox, I do make the async call and load the list and the UI updates to display the information corresponding to the selected item. However, when I reselect an item, the UI doesn't change! For example, if my original list contains three cards, I select the first card by default. Data-binding does attempt to access the PendingTransactions property on that Card object and updates the ListBox correctly. If I select the second card in the list, the same thing happens and I get the list of PendingTransactions for that card displayed. But, if I select the first card again, nothing changes in my UI! Setting a breakpoint, I am able to confirm that the SelectedCard property is being updated correctly. How can I make this work???

    Read the article

  • Database for Python Twisted

    - by Will
    There's an API for Twisted apps to talk to a database in a scalable way: twisted.enterprise.dbapi The confusing thing is, which database to pick? The database will have a Twisted app that is mostly making inserts and updates and relatively few selects, and then other strictly-read-only clients that are accessing the database directly making selects. (The read-only users are not necessarily selecting the data that the Twisted app is inserting; its not as though the database is being used as a message-queue) My understanding - which I'd like corrected/adviced - is that: Postgres is a great DB, but all the Python bindings - and there is a confusing maze of them - are abandonware There is psycopg2, but that makes a lot of noise about doing its own connection-pooling and things; does this co-exist gracefully/usefully/transparently with the Twisted async database connection pooling and such? SQLLite is a great database for little things but if used in a multi-user way it does whole-database locking, so performance would suck in the usage pattern I envisage MySQL - after the Oracle takeover, who'd want to adopt it now or adopt a fork? Is there anything else out there?

    Read the article

  • Jqplot ajax request

    - by Moozy
    I'm trying to do a dynamic content load for JQplot charts, but something is wrong: this is my javascript code: $(document).ready(function(){ var ajaxDataRenderer = function(url, plot, options) { var ret = null; $.ajax({ // have to use synchronous here, else the function // will return before the data is fetched async: false, url: url, dataType:"json", success: function(data) { ret = data; console.warn(data); } }); return ret; }; // The url for our json data var jsonurl = "getData.php"; var plot1 = $.jqplot('chart1', jsonurl, { title:'Data Point Highlighting', dataRenderer: ajaxDataRenderer, dataRendererOptions: { unusedOptionalUrl: jsonurl }, axes:{ xaxis: { renderer:$.jqplot.DateAxisRenderer, min: '11/01/2012', max: '11/30/2012', tickOptions:{formatString:'%b %#d'}, tickInterval:'5 days' }, yaxis:{ tickOptions:{ formatString:'%.2f' } } }, highlighter: { show: true, sizeAdjust: 7.5 }, cursor: { show: false } }); }); </script> and it is displaying the chart, but it is not displaying the values, looklike its not getting my data. output of: console.warn(data); is: [["11-01-2012",0],["11-02-2012",0],["11-03-2012",0],["11-04-2012",0],["11-05-2012",0],["11-06-2012",0],["11-07-2012",0],["11-08-2012",0],["11-09-2012",0],["11-10-2012",0],["11-11-2012",0],["11-12-2012",0],["11-13-2012",0],["11-14-2012",0],["11-15-2012",2],["11-16-2012",5],["11-17-2012",0],["11-18-2012",1],["11-19-2012",0],["11-20-2012",0],["11-21-2012",0],["11-22-2012",0],["11-23-2012",0],["11-24-2012",0],["11-25-2012",1],["11-26-2012",0],["11-27-2012",0],["11-28-2012",0],["11-29-2012",0],["11-30-2012",0]]

    Read the article

  • Designing DAOs around a JSON API for iPhone Development

    - by Bob Spryn
    So I've been trying to design a clean way of grabbing data for my models in iPhone land. All the data for my application is coming from JSON API's. So right now when a VC needs some models, it does the JSON call itself (asynch) and when it receives the data, it builds the models. It works, but I'm trying to think of a cleaner method whereby the DAO's retrieve the information for me and return the models, all in an async manner. My initial thought is build a protocol for my DAOs, such that the VC would instantiate a DAO and make itself the delegate. When you requested data [DAOinstance getAllUsers] the DAO would do all the network request stuff, and then when it had the data, it would call a method on its delegate (the VC) to pass the data. So I think that's a cool solution, but realized that if I needed to use the same DAO for different purposes in the same VC, my delegate method would have to branch logic depending on which DAO instance initiated the request. So my second thought was to be able to pass 'handler' selectors to the DAO object a la typical javascript patterns. So instead of an official protocol, I would say something like [DAOinstance getAllUsersWithSelector:"TheHandlerFunctionOnMyVC:"] Then when the DAO completed its network activities, it would call the passed selector on the VC, and pass the data back. So am I headed in the wrong direction entirely here? Seems like maybe an ok way to go. Any pointers or articles on designing this kind of data layer would be sweet. Thanks! Bob

    Read the article

  • Should I define a single "DataContext" and pass references to it around or define muliple "DataConte

    - by Nate Bross
    I have a Silverlight application that consists of a MainWindow and several classes which update and draw images on the MainWindow. I'm now expanding this to keep track of everything in a database. Without going into specifics, lets say I have a structure like this: MainWindow Drawing-Surface Class1 -- Supports Drawing DataContext + DataServiceCollection<T> w/events Class2 -- Manages "transactions" (add/delete objects from drawing) Class3 Each "Class" is passed a reference to the Drawing Surface so they can interact with it independently. I'm starting to use WCF Data Services in Class1 and its working well; however, the other classes are also going to need access to the WCF Data Services. (Should I define my "DataContext" in MainWindow and pass a reference to each child class?) Class1 will need READ access to the "transactions" data, and Class2 will need READ access to some of the drawing data. So my question is, where does it make the most sense to define my DataContext? Does it make sense to: Define a "global" WCF Data Service "Context" object and pass references to that in all of my subsequent classes? Define an instance of the "Context" for each Class1, Class2, etc Have each method that requires access to data define its own instance of the "Context" and use closures handle the async load/complete events? Would a structure like this make more sense? Is there any danger in keeping an active "DataContext" open for an extended period of time? Typical usecase of this application could range from 1 minute to 40+ minutes. MainWindow Drawing-Surface DataContext Class1 -- Supports Drawing DataServiceCollection<DrawingType> w/events Class2 -- Manages "transactions" (add/delete objects from drawing) DataServiceCollection<TransactionType> w/events Class3 DataServiceCollection<T> w/events

    Read the article

  • WebClient Lost my Session

    - by kamiar3001
    Hi folks I have a problem first of all look at my web service method : [WebMethod(), ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string GetPageContent(string VirtualPath) { WebClient client = new WebClient(); string content=string.Empty; client.Encoding = System.Text.Encoding.UTF8; try { if (VirtualPath.IndexOf("______") > 0) content = client.DownloadString(HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Replace("Main.aspx", VirtualPath.Replace("__", "."))); else content = client.DownloadString(HttpContext.Current.Request.UrlReferrer.AbsoluteUri.Replace("Main.aspx", VirtualPath)); } catch { content = "Not Found"; } return content; } As you can see my web service method read and buffer page from it's localhost it works and I use it to add some ajax functionality to my web site it works fine but my problem is Client.DownloadString(..) lost all session because my sessions are all null which are related to this page for more description. at page-load in the page which I want to load from my web service I set session : HttpContext.Current.Session[E_ShopData.Constants.SessionKey_ItemList] = result; but when I click a button in the page this session is null I mean it can't transfer session. How I can solve this problem ? my web service is handled by some jquery code like following : $.ajax({ type: "Post", url: "Services/NewE_ShopServices.asmx" + "/" + "GetPageContent", data: "{" + "VirtualPath" + ":" + mp + "}", contentType: "application/json; charset=utf-8", dataType: "json", complete: hideBlocker, success: LoadAjaxSucceeded, async: true, cache: false, error: AjaxFailed });

    Read the article

  • Facebook new js api and cross-domain file

    - by vondip
    Hi all, I am building a simple facebook iframe application. I've decided since the code is separate from facebook none the less, I will also create a connect website as well. In my connect website I'm trying to figure out the following: I am using facebook's new api and I am calling the init function. I can't seem to figure out where I combine my cross-domain file. There's no mention of it in their documentation either. http://developers.facebook.com/docs/reference/javascript/FB.init I am referring to these lines of code: <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({appId: 'your app id', status: true, cookie: true, xfbml: true}); }; (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); </script>

    Read the article

  • How to asynchronously read to std::string using Boost::asio?

    - by SpyBot
    Hello. I'm learning Boost::asio and all that async stuff. How can I asynchronously read to variable user_ of type std::string? Boost::asio::buffer(user_) works only with async_write(), but not with async_read(). It works with vector, so what is the reason for it not to work with string? Is there another way to do that besides declaring char user_[max_len] and using Boost::asio::buffer(user_, max_len)? Also, what's the point of inheriting from boost::enable_shared_from_this<Connection> and using shared_from_this() instead of this in async_read() and async_write()? I've seen that a lot in the examples. Here is a part of my code: class Connection { public: Connection(tcp::acceptor &acceptor) : acceptor_(acceptor), socket_(acceptor.get_io_service(), tcp::v4()) { } void start() { acceptor_.get_io_service().post( boost::bind(&Connection::start_accept, this)); } private: void start_accept() { acceptor_.async_accept(socket_, boost::bind(&Connection::handle_accept, this, placeholders::error)); } void handle_accept(const boost::system::error_code& err) { if (err) { disconnect(); } else { async_read(socket_, boost::asio::buffer(user_), boost::bind(&Connection::handle_user_read, this, placeholders::error, placeholders::bytes_transferred)); } } void handle_user_read(const boost::system::error_code& err, std::size_t bytes_transferred) { if ( err or (bytes_transferred != sizeof(user_)) ) { disconnect(); } else { ... } } ... void disconnect() { socket_.shutdown(tcp::socket::shutdown_both); socket_.close(); socket_.open(tcp::v4()); start_accept(); } tcp::acceptor &acceptor_; tcp::socket socket_; std::string user_; std::string pass_; ... };

    Read the article

  • Downloading javascript Without Blocking

    - by doug
    The context: My question relates to improving web-page loading performance, and in particular the effect that javascript has on page-loading (resources/elements below the script are blocked from downloading/rendering). This problem is usually avoided/mitigated by placing the scripts at the bottom (eg, just before the tag). The code i am looking at is for web analytics. Placing it at the bottom reduces its accuracy; and because this script has no effect on the page's content, ie, it's not re-writing any part of the page--i want to move it inside the head. Just how to do that without ruining page-loading performance is the crux. From my research, i've found six techniques (w/ support among all or most of the major browsers) for downloading scripts so that they don't block down-page content from loading/rendering: (i) XHR + eval(); (ii) XHR + 'inject'; (iii) download the HTML-wrapped script as in iFrame; (iv) setting the script tag's 'async' flag to 'TRUE' (HTML 5 only); (v) setting the script tag's 'defer' attribute; and (vi) 'Script DOM Element'. It's the last of these i don't understand. The javascript to implement the pattern (vi) is: (function() { var q1 = document.createElement('script'); q1.src = 'http://www.my_site.com/q1.js' document.documentElement.firstChild.appendChild(q1) })(); Seems simple enough: inside this anonymous function, a script element is created, its 'src' element is set to it's location, then the script element is added to the DOM. But while each line is clear, it's still not clear to me how exactly this pattern allows script loading without blocking down-page elements/resources from rendering/loading?

    Read the article

  • Google Analytics Script inside XML File

    - by mnml
    Hi, I would like to know If I can add my ecommerce analytics tags inside an xml formated file? <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-XXXXX-X']); _gaq.push(['_trackPageview']); _gaq.push(['_addTrans', '1234', // order ID - required 'Acme Clothing', // affiliation or store name '11.99', // total - required '1.29', // tax '5', // shipping 'San Jose', // city 'California', // state or province 'USA' // country ]); // add item might be called for every item in the shopping cart // where your ecommerce engine loops through each item in the cart and // prints out _addItem for each _gaq.push(['_addItem', '1234', // order ID - required 'DD44', // SKU/code 'T-Shirt', // product name 'Green Medium', // category or variation '11.99', // unit price - required '1' // quantity - required ]); _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga); })(); </script>

    Read the article

  • Get Classic ASP variale from posted JSON

    - by Will
    I'm trying to post JSON via AJAX to a Classic ASP page, which retrieves the value, checks a database and returns JSON to the original page. I can post JSON via AJAX I can return JSON from ASP I can't retrieve the posted JSON into an ASP variable POST you use Request.Form, GET you use Request.Querystring......... what do I use for JSON? I have JSON libraries but they only show creating a string in the ASP script and then parsing that. I need to parse JSON from when being passed an external variable. Javascipt var thing = $(this).val(); $.ajax({ type: "POST", url: '/ajax/check_username.asp', data: "{'userName':'" + thing + "'}", contentType: "application/json; charset=utf-8", dataType: "json", cache: false, async: false, success: function() { alert('success'); }); ASP file (check_username.asp) Response.ContentType = "application/json" sEmail = request.form() -- THE PROBLEM Set oRS = Server.CreateObject("ADODB.Recordset") SQL = "SELECT SYSUserID FROM WCE_UK.dbo.t_SYS_User WHERE Username='"&sEmail&"'" oRS.Open SQL, oConn if not oRS.EOF then sStatus = (new JSON).toJSON("username", true, false) else sStatus = (new JSON).toJSON("username", false, false) end if response.write sStatus

    Read the article

< Previous Page | 33 34 35 36 37 38 39 40 41 42 43 44  | Next Page >