Status 501 - Method Not Implemented - when use Backbone - backbone.js

When I send a POST method to a valid URL with Backbone, the server is returning this:
Method Not Implemented
POST to /clientes/login not supported.
What can it be?
EDIT: If I use a form with method="post" without Backbone the server is returning Login Successfully, like it has to do.
Thank you!

The URL may be valid, but that doesn't mean the server it is on supports whatever http method you are sending it with. In this case it seems the server does not have any support for POST. So you can not use POST on that server until the server is built to handle it. Try contacting who ever is in charge of the server.

Related

Best method to check from (JS) client side, if you are connected to server

We are making an application in React, and would like to check after xxx seconds from client end, that if we are connected to our server (WEB API's).
I would like to know what is the best way to achieve this?
The instant approach comes to my mind is to call the webApi after xxx seconds using setTimeout from the client side and check the response status.
Your approach sounds good. But, as I understand it, a web API is meant
to be called asynchronously and is mostly stateless. Thus, trying to know
if you are connected to your API feels weird to me.
It would make more sense if you were connected to your server using
a websocket, which pseudo real-time. Then, you could check for a connection
or disconnection.

Is it possible to update an AngularJS expression via an API call through a Service?

I'm looking for a way (and not even sure if this is possible) to update an Angular expression on my HTML page when data is sent to an API.
For example, say I have $scope.message on my .html page. Is there a way I can send a message to an API (e.g. http://...?message=foo) and have my page update with the message sent?
Also, I need the $scope.message to be updated in an Angular Service so it is available to multiple pages within my website.
I am wanting this to be a live update, but if not, I am happy with some code executing on a timer or something similar.
Any suggestions appreciated.
UPDATE
I'm guessing it may not be possible, but just in case I haven't explained it correctly, I'll try and simplify it.
I can only find information about using AngularJS to send GET commands OUT to a URL and receive data back. I need to send a JSON string TO my Angular site to update a variable. So basically as a field updates in my database, I want another server application to send an alert to my Angular site to update the status of this value live. I don't really want to run a constant check of the database if I don't have to.
I am open to any other suggestions on how to achieve this.
if you don't care about old school browsers, you can try using WebSocket, it is similar to a TCP socket, which allows you to push from server to client. I would create a service that manages the websocket connection, and update scope when receiving message. Hope this help. More info here: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API

"Cross-origin-request blocked". How to overcome that?

When I am calling rest services using ionic and angularJS It's getting "Cross-origin-request blocked". How to overcome that?
Thank you.
Better to Add https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en to your chrome extension.
<cfheader name="Access-Control-Allow-Origin" value="*">
<cfheader name="Content-Type" value="text/javascript">
You will set above text on your server page that means which page you want access from remote. And one more thing i am using coldfusion server so above code looks in cf code format. So you will change syntax which server you have use.
A cross-origin request is a request from one domain to another. For security purposes you cannot get around that unless you control the server of the receiving domain. To solve your issue you must, therefore, make the request from and to the same domain. For more information, see: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
You can bypass them in certain web browsers.
https://www.thepolyglotdeveloper.com/2014/08/bypass-cors-errors-testing-apis-locally/
Chrome has been most successful for me.

How can a server communiate with two clients at once (JavaScript, HTML, PHP)?

I got an assignment to do and for that I could use any www technology like HTML, JavaScript, PHP etc. I'm really sorry to say that I haven't studied any of these technologies. Therefore I took few tutorials and skimmed through them searching for answers.
I found solutions for many problems but one problem yet unsolved. It is this:
I want two clients to communicate through a server for this assignment. One send a message, server processes it and forwards it to the next.
None of PHP tutorials showed me anyway of doing this. All of them talked of communication between one client with a server.
Please help. Show me a way to do this. Thanks.
Currently, without reverting to cutting-edge (and possibly hacky/unreliable) techniques, your PHP server cannot initiate communications with a page you've already loaded into a web browser. This is a result of the way the HTTP protocol works.
One way to solve this would be polling on the "receiving" end for data. Something like a publish-subscribe pattern.
One way to do this would be:
One client sends data to the server using an HTTP request (XHR aka AJAX) specifying the target for this data (the other client).
The server stores this data in a persistent storage (local file, database, etc).
The second client periodically sends a request to the server asking if there's any new data for it to consume. This can be done using setInterval and XHR in JavaScript.
I would suggest you take a look at:
http://en.wikipedia.org/wiki/Publish/subscribe
And also, for a cutting edge way to do this, check out Socket.IO:
http://socket.io
You might want to Google on "php chat server." Building a chat server is a simple way to get started.
http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-simple-web-based-chat-application/
http://code.jenseng.com/jenChat/

How do I setup a really simple WCF Data service and entity model that works?

Ok this is going to seem really daft but but essentially this is what i'm trying to do in a nutshell ...
http://msdn.microsoft.com/en-us/library/dd465161.aspx
The problem is that when I create the WCF Data Service and browse to it everything looks good at the root level and as soon as I leave the root I get http 500 errors.
I get no decent information on how to fix the error or what went wrong it says "Internal server error" ... not helpful.
So my question is sort of twofold ...
How do I setup a simple WCF Data service that relies on an entity model then bind some simple data to a listbox or something in a WPF client?
but also ...
How do I debug those http 500 errors?
Just for clarification:
I followed the steps here ...
http://msdn.microsoft.com/en-us/library/dd728275.aspx
... to create the model and service.
The root url "http://localhost/Northwind.svc" works fine.
Browsing to "http://localhost/Northwind.svc/Orders" causes a http 500.
This helps a LOT:
Link
Also download fiddler you can use it to monitor requests/responses (See this)
I would start by attaching the debugger to your service when you use your browser to access it.
You might want to try a different client because there usually is a response from a service besides the 500 errorcode, but a browser only shows a 500 error page.

Resources