angularjs - how to get results of my webservice with jsonp? -


I want to call one of my web server through jsonp.

/ code>

code> $ http.jsonp ('http://example.com/files?callback=JSON_CALLBACK') .Service (data) {console.log (data); $ scope .folders = data;});

console.log is not showing up .... what am I doing?

My Web service returns

  JSON_CALLBACK (["folder1", "folder2"])   

? Should I do it manually in my API? Browser does not do this automatically?

You are currently returning ( ["folder1", "folder2"] < / code>) is not valid. The JSON result should be wrapped up with the Javascript function call to be JSONP.

For example, when you use URLs like this:

  http: // example.com/files?callback=JSON_CALLBACK   

Angular function will replace the JSON_CALLBACK parameter with the function name (built internally) such as:

  http://example.com/ Files? Callback = angular.callbacks._0   

Then your server will need to be able to read that callback parameter and return results as follows:

  Angular Call (.   

This is not an automatic mechanism, you must apply that logic to your web server.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -