Returning empty data from database in angular js - angularjs-service

I am using angular js http.get method to fetch data from database with php script, but having problem when php returns empty record. How can I solve this problem?

A minimalist answer for a minimalist question
if(yourObjectFromDatabase != null) {...}

Related

MVC Controller.File returns blank pdf

I lost a lot of time on this issue so i will go straight to topic.
I am receiving empty pdf with correct number of (blank)pages. My action is:
public FileResult DownloadDoc()
{
//Authorization
//initialising filename
//getting content
return File(Convert.FromBase64String(content), "application/pdf", filename);
}
Content is Base64 string and it is correct. I know because when i use system.io.file.writeallbytes to make document i'm getting correct one.
I also tried to return file over Response and result is the same.
There are no (I hope) razor syntax errors.
This part of code used to work, and he stopped despite no one made no change. Maybe IIS was restarted.
If anyone can tell me what else to try ... tnx
p.s. I am looking for way without saving doc on server side.
Sorry,
an error was in javascript that saves file after returning from the server.
If you have similar issues check inner properties of the Blob object!

How to get property fileds in Jersey?

Currently I'm developing the application which gets the property fields in front end and
server handles this request using jersey.
In jersey I need to use more number of path parameters. So I'm looking for the solution
which gets the property fileds in a single element itself.
Any help would be greatly appreciated.
Thanks
you can try sending JSON or you can send your data by separating them with a delimiter like Comma(,) or Pipe(|)

rails, cannot get params from url

I'm trying to use Google Federated Login REST API. I can succesfully reach out to the google server and validate a user but I cannot pull parameters from the return url
for example:
http://mysite.com/login/return?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud...
All the variables in that return string are not accessible in the params array. I have no idea how to get them out. requst.url, request.query_parameter, and all similar calls do not return the query string.
I think i found the issue. I was using the open-uri library to make the call to google's endpoint url so it may have been stepping outside of the normal rails response/request cycle. I've since used Net::HTTP requests and parse the information from the response.
So I have a very similar issue, where I'm actually building a Rails-based openid provider but being consumed by another Rails app. I basically adapted the code from
The whole URL was:
http://localhost:3000/openid?openid.assoc_handle=%7BHMAC-SHA1%7D%7B5193d33f%7D%7BdBrUwQ%3D%3D%7D&openid.claimed_id=http%3A%2F%2Flocalhost%3A3000%2Fopenid%2Fwarren&openid.identity=http%3A%2F%2Flocalhost%3A3000%2Fopenid%2Fwarren&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fextensions%2Fsreg%2F1.1&openid.realm=http%3A%2F%2Flocalhost&openid.return_to=http%3A%2F%2Flocalhost%2Fsession%3F_method%3Dpost%26return_to%3D&openid.sreg.required=nickname%2Cemail
I had a similar problem where the only parameters being reported were:
{"action"=>"index", "controller"=>"openid"}
So, suspecting that some parameter (maybe a period?) was causing it to hiccup, I went through and deleted them one by one until I found that deleting the following parameter enables the entire thing to go through correctly:
openid.mode=checkid_setup
That left all the remaining parameters correctly being parsed:
{"openid.assoc_handle"=>"{HMAC-SHA1}{5193d33f}{dBrUwQ==}",
"openid.claimed_id"=>"http://localhost:3000/openid/warren",
"openid.identity"=>"http://localhost:3000/openid/warren",
"openid.ns"=>"http://specs.openid.net/auth/2.0",
"openid.ns.sreg"=>"http://openid.net/extensions/sreg/1.1",
"openid.realm"=>"http://localhost",
"openid.return_to"=>"http://localhost/session?_method=post&return_to=",
"openid.sreg.required"=>"nickname,email",
"action"=>"index",
"controller"=>"openid"}
I'm now trying to find why openid.mode causes this issue. It fails even if I change it to openid.mode=5, so it's the key, not the value, causing the problem.
Suspecting the ".mode" part of the string for the trouble (maybe ".mode" is a filetype or something being parsed by the routing?) I am looking towards this post on allowing periods, but it only applies to the value, not the key: rails routing and params with a '.' in them
Will report back if I find more.
Update: I tried, in another Rails app, adding ?openid.mode=0 to the end of a URL -- ".mode" does not result in a parameter being read, but ".modes=" does and so does ".mod=". This confirms that ".mode" is causing a params parsing error.
Update 2: yikes... actually "?a.mode=0" does work. So far, only the complete string "openid.mode" does not work, and this is across various Rails apps. "?openid.mode" with nothing else results in: Parameters: {"openid.mode"=>nil}, but "?openid.mode=" with nothing after the "=" fails to pass any parameters besides action & controller. Very odd.
Update 3: OK, figured it out, I believe -- the params were getting sanitized i.e. deleted by the rack-openid gem, in that gem's path: /lib/openid.rb:168, "sanitize_query_string". This seems to be incompatible with the example I was working with: https://github.com/openid/ruby-openid/tree/master/examples/rails_openid. Going to override that method.
Final update: I replaced this line:
oidreq = server.decode_request(params)
with this line, since we could no longer use the now-empty params hash:
oidreq = server.decode_request(Rack::Utils.parse_query(request.env['ORIGINAL_FULLPATH']))

In rails is there a difference between mysite/show/1.js and mysite/show/1.json

In my rails 3 app, if I want a request to return json data does it matter if I use
mysite/show/1.js
or
mysite/show/1.json
I know it seems obvious to use the json version but in my responses they look the same to me.
First of all: It depends on the way you implement the respond_to block.
With 1.json it should be clear that it delivers data as JSON.
1.js could return Javascript that is evaluated by the page that requested it. In the early Rails/Ajax days this used to be done with RJS templates. See http://www.codyfauser.com/2005/11/20/rails-rjs-templates

how to handle unicode data in delphi7

in my application ,i am sending data from my application to database
i am getting some odd characters in my database like this
i am sending my data like this
var
w:widestring;
u:utf8string;
begin
w:=data //data is function to get some info(string)
u:=utf8encode(w);
sendfn(u);
end;
i am using utf8_decode(my get data) in my php code before adding to my database.
and my database and tables collation is utf8_general_ci
can anyone help me in this issue
It's an educated guess, but does the Data function return an UTF-8 string instead of a WideString? I think the error could be in this Data function that you're calling, which returns the data in the wrong string format.
The php function utf8_decode converts characters from utf-8 to ISO-8859-1. If the path your data take (the browser or whatever component you use to send your data to the web server (http request, your php installation, your webpage and your database connection) from your delphi app to your database that is behind you webpage are able to support and configured to use utf-8 data you don't need the utf8_decode function, you can just insert your data the way it comes.
If you haven't already configured php to work with UTF-8, be aware that it is difficult and never works 100% (for me at least it never did), so maybe it would be better for you to use data in your locale encoding.

Resources