w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
REST API and clients - removing previously seen items - client-side or server-side?
First off, if the requirement is to not show a user products they've seen before on any device/platform (for example if they used the app on their iphone then ipad/ipod) then you'd definitely have to do it server side (as the app cannot know what the user has seen on other devices unless you are storing it on the server). Assuming, it is a device specific requirement, I would think your goal would be to minimize (potentially unreliable or slow) network traffic to optimize the iphone experience. Syncing back and forth with the server will require extra network traffic, which may fail at times. Which would lead to a conclusion of client side storage. Unless your users are going to be seeing some huge number of products that would chew up disk space, but I assume the amount of data you store

Categories : IOS

Does MVC Razor generate HTML for the template in the view on client side or server side?
I want to understand where the Razor View Engine actually generates the HTML from the templates that we create in the view It happens on the web server. Once the HTML is fully created on the web server, this HTML is sent to the client browser.

Categories : HTML

Ember user authentication (Client side and Server Side completely separated)
Ember-auth isn't necessarily just for apps. You can configure the endpoints like signInEndPoint and signOutEndPoint to point to the urls that need to be hit on your server to do authentication. Also there isn't any reason to bundle the client-side and server-side in the same repository here. The demo does this because the asset pipeline support in rails is very convenient for demoing, typically for avoiding a front-end build step. You can treat it as just a library file that you include alongside ember.

Categories : Ember Js

Crop and upload image on client-side without server-side code involve
The solution i used: First I use a 3rd party javascript library to select the crop area like jCrop. Once i got the coordinates (x1,x2,y1,y2), i draw a copy of an image to a canvas. var canvas = document.getElementById('drawcanvas'); var context = canvas.getContext('2d'); canvas.width = canvas.width; // clear canvas var imageObj = new Image(); imageObj.onload = function() { // draw cropped image // ... context.drawImage(imageObj, sourceX, sourceY, sourceWidth, sourceHeight, destX, destY, sourceWidth, sourceHeight); var dataURL = canvas.toDataURL(); }; imageObj.src = // image url After i drew the canvas, i converted the canvas to a DataURL which is in base64 format. On

Categories : Javascript

Timer, timezone, server side time, client side countdown
You can use php DateTime for this. The current time The midday time The midnight time Here is an example. $now = new DateTime; $morning = new DateTime('08:00'); $night = new DateTime('22:00'); // next time is night if( $now > $morning && $now < $night ) { $time = $now->diff($night); } // next time is day else { $time = $now->diff($morning); } $target = $time->format('%h:%i:%s'); // returns a string.

Categories : PHP

Parsing Google Maps API GeoCode - server side or client side?
Is this a website or an application that you need to hit geocoding servers on every request? If so, you should use client-side. If you have some predefined latLng values then you can use server side geocoding and cache the results for a couple of hours. This way, you probably won't need to worry about quota. From Google Developers' site: When to Use Client-Side Geocoding The basic answer is "almost always." As geocoding limits are per user session, there is no risk that your application will reach a global limit as your userbase grows. Client-side geocoding will not face a quota limit unless you perform a batch of geocoding requests within a user session. Therefore, running client-side geocoding, you generally don't have to worry about your quota. See here

Categories : Google Maps

Performing both client side and server side functions on button click - Specific Scenario
ASPX: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="js/jquery-1.10.2.min.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $('#lblCheck').hide(); $('#btnProceed').click(function () { var $this = $('#chkTerms') if ($this.is(':checked')) { $('#lblCheck').hide(); return true; } else { $('#lblCheck').show();

Categories : C#

How to get data from client side(android) to server side(ROR) in create action(post method)?
The request made from the client side is somewhat similar to this if I'm right: The post data from your client side is of the form: &content=valueIWantToSend In the ROR application, in the def create method, params[:content] will equal valueIWantToSend. Either change params[:post] to params[:content] on the server-side or change content to post on the client-side (Inside the try block)

Categories : Ruby On Rails

How to make client side click event handler to request a server side method
Use can do like this : $('a').click(function () { var data = { userName: $(this).attr("id") }; var dataVal = JSON.stringify(data); $.ajax({ type: "POST", url: "Default.aspx/loadNewPage", contentType: "application/json; charset=utf-8", data: dataVal, dataType: "json", success: function (id) { alert("loaded"); } }); }); [WebMethod] public static void loadNewPage(int id) { // do the loading of the new HTML, etc. } You can know more about Jquery AJAX call over here.

Categories : C#

Sending from server-side to client-side multiple PartialViews asynchronously with an undefined delay
Use SignalR is one option but if you wanna do yourself instead of inherit your controllers class from Controller, inherit it from AsyncController. Controllers that inherit from AsyncController can process asynchronous requests, and they can still service synchronous action methods. public class HomeController : AsyncController { public void ExtensiveTaskActionAsync() { AsyncManager.OutstandingOperations.Increment(); Task.Factory.StartNew(() => DoExtensiveTask()); } private void DoExtensiveTask() { Thread.Sleep(5000); // some task that could be extensive AsyncManager.Parameters["message"] = "hello world"; AsyncManager.OutstandingOperations.Decrement(); }

Categories : C#

Send gridview data from client side to server side at once
You should add loader for this kind of functionality. I hope you should be using update panel. You can add update progress control for the time request is processing on server side. It will hint the user to wait. You can also use ajax request by jquery to do similar kind of work.

Categories : Javascript

php's server side associative arrays to html's client side
You haven't mentioned jQuery in your tags, but that is what I would look at. Specifically, the jQueryUI library, which runs on top of jQuery. jQuery is a javascript library that is more efficient (less typing, do more with less code) than classic javascript. See the jQueryUI sortable widget, here. For jQuery tutorials: Alex Garret's jQuery tutorials at the thenewboston.com Alex Garret's website with many more tutorials.

Categories : PHP

Pass a user geolocation from client side to server side
You have to add callbacks for success / error to trigger an event when the user accepts to share their location: navigator.geolocation.getCurrentPosition(success, error); function success(position){ var lat = position.coords.latitude; var lon = position.coords.longitude; document.getElementById('location').value = lat + ',' + lon; } function error() { // do something with the error message }

Categories : Javascript

How to invoke server-side function from client-side using socket.io?
Client.js <script src="/socket.io/socket.io.js"></script> <script> var socket = io.connect('http://localhost'); $("#urAnchorTagId").click(function(){ socket.emit('urEvent','urData'); }); </script> Server.js var app = express(); var server = http.createServer(app); var io = require('socket.io').listen(server); server.listen(8080); io.sockets.on('connection', function (socket) { socket.on('urEvent', function (data) { function init(){ //ur task }; }); });

Categories : Node Js

call server-side function from client-side in mvc3
You have to modify you method public ActionResult Media() { //do some stuff here return View(); } to something like public JsonResult Media() { //do some stuff here return Json(new { myData = RenderPartialViewToString("ViewName", optionalModel), errorMessage = error }); } Add following method with reference to ASP.NET MVC Razor: How to render a Razor Partial View's HTML inside the controller action protected string RenderPartialViewToString(string viewName, object model) { if (string.IsNullOrEmpty(viewName)) viewName = ControllerContext.RouteData.GetRequiredString("action"); ViewData.Model = model; using (StringWriter sw = new StringWriter()) { ViewEngineRe

Categories : Javascript

connect server-side computing with client-side visualization
First of all, I would suggest JSON rather than XML to be used for exchange format, it is much easier to parse JSON at the javascript side. Then, speaking about the architecture of your app, I think that it is better to write a server web application in Python to generate JSON content on the fly than to modify and serve static files (at least that is how such things are done usually). So, that gives us three components of your system: A client app (javascript). A web application (it does not matter what framework or library you prefer: django, gevent, even Twisted will work fine, as well as some others). What it should do is, firstly, giving the state of the points to the client app when it requests, and, secondly, accepting updates of the points' state from the next app and storing the

Categories : Javascript

Wanting to POST a Javascript Variable (From Client Side) to PHP File (Server Side) with AJAX JQUERY call
There could be many different things going wrong here. First, I think your jQuery's $.post snippet is wrong (you're missing a matching curvy bracket and a semicolon at the end) so I find it weird that your server informs you about a successful POST. I'd change this: function() { jQuery.post( 'packed_data.php', {'packed_dat': packed_dat}, function() { alert('Write OK!'); }) Into this: $.post('packed_data.php', { packed_dat: packed_dat }, function (data) { alert('Write OK!'); }); And then, in your packed_data.php script, give $uid a default value so in case $_POST['packed_dat'] isn't set, it still creates a file or not (and from that distinguish whether the problem is in the server side or in the client side).

Categories : PHP

Accessing Client-Side arrays on Server Side ASP.Net
A valid approach would be to serialize them and assign it to a runat="server" hidden field. You'll be able then to access the array deserializing Value property. You can easily handle serialization with json format or comma separated values.

Categories : C#

Grails - Client Side vs Server Side Templating
I believe people start using client side frameworks to manage growing client side needs (Starting with backbone, ending with Angular/Ember). If your needs are not so severe then you might want to use client side temples like handlebars or mustache or underscore You might have one gsp file filled with various client templates included on page, then just use javascript to paint these templates on page using sample data or data from server. I do not agree that gsp templates lose in this case unless you are building fully dynamic experience or single page app which is usually not the case with grails. EDIT: I have just had a project when I had to consider if I need to move to client side templates all together, was using backbone. And there was one case when having server-side templates w

Categories : Grails

client side and server side page generation
From my experience, there are two scenarios in which you'd want to render client-side: You are building a pure client-side JS application. You want to serve the data for different platforms (web, desktop, mobile native). Unless you identify your page with one of the previous scenarios (which I assume you don't), I recommend you to render in server side. Although the response is going to be bigger (server side computing time is negligible), the perceived speed compared to client side rendering is going to be faster. If you need to serve a very big page, note that you could autoload chunks of HTML via AJAX whenever the user reaches the bottom of the page without the need of client side templates.

Categories : Javascript

Server-side internationalization vs client-side?
Doing clientside i18n is growing - as implementing clientside applications in web gets more mature. you might get inspired by http://i18next.com/pages/doc_templates.html

Categories : Javascript

How do I write a client side Java script to run on a Node JS server
From what I can understand you are looking for an alert function in node. There really isn't one. If you just want to print something to the console ( the ugly black box ) you can use console.log like this: console.log(”Oh..Node what have you done?") If you would like to not change a line of code you could wrap console.log in an alert function like this: var alert = console.log; And it will work as is. If you are looking for Dom interactions you can try jsdom. EDIT : If you want a javascript file which is capable of being run on both the client side and the server side you would do something like this. if (typeof(process) !== 'undefined' && typeof(process.stdout) !== 'undefined') { console.log('You are running Node.js'); } else { alert("Why use console.log(

Categories : Javascript

Java Script get data from server (asp.net) and save it in local storage (client side)
You are trying to throw in an object into localStorage Change localStorage.setObject("teamworkGantDemo", prj); to localStorage.setItem("teamworkGantDemo", JSON.stringify(prj)); or simply localStorage["teamworkGantDemo"] = JSON.stringify(prj) But if you are insistent on using a wrapper around this, you could do this : Storage.prototype.setObject = function(key, value) { this.setItem(key, JSON.stringify(value)); } Storage.prototype.getObject = function(key) { return JSON.parse(this.getItem(key)); } Then use it this way : localStorage.setObject("teamworkGantDemo", prj);

Categories : Javascript

Is there a JavaScript (client-side) JSON library that integrates well with JSON.NET (server-side) and supports the "preserve references" feature?
There are few options: Douglas Crockford's original JSON library has plugin called cycle.js that resolved circular references. Also see this answer which has enhanced version of method to resolve references: Resolve circular references from JSON object. Cereal which handles circular references and object graphs better. CircularJSON which is very small and does exactly what it says. Having said that, I would probably refactor my design to avoid circular references because JSON is usually core component and you probably want to use mainstream libraries which is very well tested and supported. One way to avoid circular references is just to create lightweight shim objects and serialize them instead. Alternatively implement custom interface (if you have access to class) that overrides seri

Categories : Json

Client side MVC instead of server side MVC
Was to long for a comment I guess the tricky part is indeed the point you mentioned f we link each other, they will perfectly look like a complex web app. Because each MVC framework uses a different approach to tackle usual problems you have in modern web-apps, like routing, data binding, application state and rendering DOM elements, so I think you would end up having multiple frameworks doing tasks that overlap substantially, thus forcing you to deactivate or disable some of the built-in functionality of one or the other framework making your frankenstein-app :) very difficult to maintain. A good example is jQuery-mobile & ember.js, both have a routing system, jQuery uses the DOM to hold state ember.js holds it's state completely in javascript which is much faster. I had a s

Categories : Ruby On Rails

asp.net/javascript creating cookies, advantages creating client side or server side?
Are there any alternatives creating the cookie via server side code or via javascript? No. Actually my server side is a asp.net rest service so probably this isn't a good idea? REST services usually do not deal or know about cookies. They could but it's not a common practice. REST services are using different techniques of authentication, such as sending some value in the Authorization HTTP request header. Are there any advantages or disadvantages in using either method? It would really depend on your scenario and what kind of information you are attempting to store. For example with a server side script you could create an HttpOnly cookie which is not accessible by client scripts, only by server side scripts. In any case you should not be storing sensitive information in

Categories : Javascript

sql merge tables side-by-side with nothing in common
Assuming, you want to match guys up with girls in your example, and have some sort of meaningful relationship between the records (no pun intended)... Typically you'd do this with a separate table to represent the association (relationship) between the two. This wouldn't give you a physical table, but it would enable you to write an SQL query representing the final results: SELECT Girls.ID AS GirlId, Girls.Name AS GirlName, Guys.ID AS GuyId, Guys.Name AS GuyName FROM Couples INNER JOIN Girls ON Couples.GirlId = Girls.ID INNER JOIN Guys ON Couples.GuyId = Guys.ID which you could then use to create a table on the fly using the Select Into syntax SELECT Girls.ID AS GirlId, Girls.Name AS GirlName, Guys.ID AS GuyId, Guys.Name AS GuyName

Categories : SQL

Devexpress mvc extensions. Whether these extensions are server side or client side?
That depends on what you mean by "are server side or client side". It is not a pure Javascript library. They use features of the MVC framework in order to do their magic, so I'd say they are both (but not just one side). More specifically, they implement custom controls that you include in your views. The controls have settings and such that you set on server side. However, the code generated relies on Javascript so they run on the client (using ajax calls when necessary). See documentation and examples here: link

Categories : Asp Net Mvc

In client side MVC, who should handle client-server communication?
The model layer should be interacting with data source. In case of client-server setup where you have two separate and independent triads, the data source for client's model layer would be server's presentation layer. Basically, your client-side's model layer becomes the user of server-side.

Categories : Web Services

Is there a client+server-side MVC JS framework
rendr (backbone with server-side support) meteor (very real-time oriented)

Categories : Javascript

client and server side validation
You could use intval to convert the string size into an integer, for example intval('12 inch') will return 12.

Categories : PHP

Should I send user tweet from browser side or server side?
To answer my own question after a bit of investigation: For a web application, the Oauth token is generally preserved on the server, and REST APIs are also called from server side. The calls can be made synchronously, so task queue is not necessarily needed. For a native app, Oauth is generally handled within the app. A webview is used to load the authenciation URI, and when it redirects, the access code is captured in the URL. The access code is used by the app to obtain the access token. For native apps, there is another authentication method generally referred to as SSO. It switches to the service provider's native app, and let user grant acces there, then switching back to your app. This is more convenient for the user, as the native client is almost always in logged-in state, savin

Categories : Javascript

how to download a pdf file stored in a server in client side in node.js server
Send the correct mime-type, and then the content of the pdf. fs.readFile('temp/xml/user/username.pdf',function(error,data){ if(error){ res.json({'status':'error',msg:err}); }else{ res.writeHead(200, {"Content-Type": "application/pdf"}); res.write(data); res.end(); } }); I'm assuming res is your response object. Ah but you are using Express. Use Jonathan's answer instead.

Categories : Node Js

How can I "save" variables client side so I can use it during some other java script event?
To store locally on client side: localStorage.nameId = nameId; localStorage.personId = personId; As commented, probably safer: localStorage.setItem("nameId",nameId); localStorage.setItem("personId",personId); and get their values: nameId=localStorage.getItem("nameId"); personId=localStorage.getItem("personId");

Categories : Javascript

Android client and server side programming
There are 2 points for this: If you run the app on the simulator please use the IP address as your machine IP address, don't choose yourself as "10.100.102.15". About the port, please choose another port like 50907 or something like that (stay away from KNOWN-PORT like 8080, that usually occupied as the INTERNET port). Try again and hope this helps.

Categories : Android

Mixing Client-/Server-Side Tests
I wouldn't mix these two types of tests at all. You have several different concerns here. You can still get full test coverage without having to combine tests like you are describing. Client side unit tests (using Karma, Mocha, etc.) validate that the JavaScript code is behaving as expected. Server side unit tests (using JUnit or whatever unit testing framework exists for your back end) validate that the server code is behaving as expected. Integration or end-to-end tests (using Selenium) validate generally validate that multiple components are working together correctly. You can use a mock back-end for these if necessary. You can create Karma/Mocha unit tests to verify the details of whatever processing may exist for that file upload action. Here, you should be testing edge cases of t

Categories : Javascript

Form client and server side validation issue
What about applying a specific error classes depending if on if js or php error. <span class="jsError">Some Error</span> <span class="phpError">Some Error</span> In your css you would just hide the js errors. .jsError { display:none; } In your js, hide php errors and do your normal jQuery validation there which will show only the js errors. $(function() { $('.phpError').hide(); //after doing your jsValidation show js error only }); This way if js is disabled, only the PHP errors will appear.

Categories : PHP

How to stop server process during a post on client side?
You can create static class/singleton in service layer with methods which will run and stop your long process. In controller you can make some actions which will manage this singleton by user requests.

Categories : C#

forwarding server side DDP connection collections to client
I realize that this is a pretty old question, but I thought I would share my solution. I had a similar problem as I have two applications (App1 and App2) that will be sharing data with a third application (App3). I couldn't figure out why the server-side of my App1 could not see the shared collections in App3...even though the client-side of App1 was seeing them. Then it hit me that the server-side of my App1 was acting like a "client" of App3, so needed to subscribe to the publication, too. I moved my DDP.connection.subscribe() call outside the client folder of App1, so that it would be shared between the client and server of App1. Then, I used a Meteor.setInterval() call to wait for the subscription to be ready on the server side in order to use it. That seemed to do the trick. Here'

Categories : Meteor

GWT server side method should only be called by one client at the same time
From the docs: Multithreading and Synchronization: JavaScript interpreters are single-threaded, so while GWT silently accepts the synchronized keyword, it has no real effect. Synchronization-related library methods are not available, including Object.wait(), Object.notify(), and Object.notifyAll(). The compiler will ignore the synchronized keyword but will refuse to compile your code if the Object's related synchronization methods are invoked.

Categories : Gwt



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.