0

I've got a simple angular sql-php-json data fetching.

The code works until some record. Then it's trows an error. It works with 51 record, crashes with 52... Obviously I need all the data. :)

What am I missing? Thank you.

Console error:

{}

javascript:

    var app = angular.module('myApp', []);
    app.controller('Ctrl', function($scope, $http) {
      $http.get(file)
      .then(function (response) {$scope.names = response.data.records;},
        function(error) {console.log(JSON.stringify(error));}
     );
  });

php:

header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");    
include("connect.php");
$result = $conn->query("SELECT id, nev, cim, kapcsolat, bankszamlaszam, adoszam FROM szallito ORDER BY nev LIMIT 52"); 

$outp = "";
while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
    if ($outp != "") {$outp .= ",";}
    $outp .= '{"id":"'  . $rs["id"].'",';
    $outp .= '"nev":"'. $rs["nev"].'",';
    $outp .= '"cim":"'. $rs["cim"].'",';
    $outp .= '"kapcsolat":"'. $rs["kapcsolat"].'",';
    $outp .= '"bankszamlaszam":"'. $rs["bankszamlaszam"].'",';
    $outp .= '"adoszam":"'  . $rs["adoszam"].'"}';
}
$outp ='{"records":['.$outp.']}';
$conn->close();

echo($outp);
3
  • Should be stringify. You could consider deleting the post if it's just a typo. I don't think this post will help others. Commented Nov 28, 2017 at 13:43
  • 1
    While JSON.stringify is spelled wrong - that's only prohibiting OP from logging the error - fix the typo and please post the actual error you're receiving from the server. Commented Nov 28, 2017 at 13:51
  • I've changed it, the error remains. I mean the new error is: {} Commented Nov 28, 2017 at 14:38

1 Answer 1

1

It is JSON.stringify

console.log(JSON.stringify(error));
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry it doesn't helped, like I said the error remains... which is like this in the console.log -> {} (that's all what it says, and crashes. )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.