Search code examples
phpangularjsjsonhttpserver

Angular JS http Bad Data Error


I am new to Angular. So I decided to make a sample login using Angular. I send username and password to HTTP server. What I need is to get access into dashboard only if both username and password from the DB [php] should be same as user entered data.

I wrote the code and when tried to click on login button, I am getting the following error.

Error: [$http:baddata] http://errors.angularjs.org/1.6.9/$http/baddata?p0=%3Cbr%20%2F%3E%0A%3Cb%3EFatal%20error%3C%2Fb%3E%3A%20%20Uncaught%20Error%3A%20Call%20to%20undefined%20function%20mysql_num_rows()%20in%20C%3A%5Cxampp%5Chtdocs%5Cwebpage%5Cserver.php%3A20%0AStack%20trace%3A%0A%230%20%7Bmain%7D%0A%20%20thrown%20in%20%3Cb%3EC%3A%5Cxampp%5Chtdocs%5Cwebpage%5Cserver.php%3C%2Fb%3E%20on%20line%20%3Cb%3E20%3C%2Fb%3E%3Cbr%20%2F%3E%0A&p1=%7B%7D Stack trace:

I am confused and don't know how to fix the issue. Please see the files attached and help me to solve this issue.

https://pastebin.com/MKsHVuFX - main.js
https://pastebin.com/JdSjf0Fe - dashboard.html
https://pastebin.com/hR6xwXde - server.php
https://pastebin.com/GGzetT3v - login.html
https://pastebin.com/YUiNw6z2 - index.html

Solution

  • Try to visit the url in the error message, because it's seems that your server side code is not retuning a valid json response that is mandatory for angularjs.

    Check your server.php code, maybe is returning some warning/error.