Saturday, 15 February 2014

javascript - ajax-loading doesn't stop or infinite loop? -



javascript - ajax-loading doesn't stop or infinite loop? -

i'm not sure if ajax issue or if have infinite loop, i'm trying values of 1 page another.

my 1st page cakephp contoller:

$arr = ($this->phone->find('all')); $arr2 = json_encode($arr); echo $arr2; $_get ['var1'] = $arr2; die();

my 2nd page gets , displays output one

<!doctype html> <html> <head> <meta charset="utf-8"> <title></title> <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> <script src="sizeof.js"></script> <script type="text/javascript"> var results; { $.ajax({ type: 'get', url: 'http://localhost/restdemo/', data: { var1: results }, success: function(data) { console.log('success'); var output = json.parse(data); (x = 0; x <= output.length - 1; x++) { var hello = (output[x]["phone"]["name"]); document.write('<table border="1" cellspacing="1" cellpadding="5">'); document.write('<tr>'); document.write('<td>' + hello + '</td>'); document.write('</tr>'); document.write('</table>'); } } }); } </script> </head> <body> </body> </html>

i getting desired results page doesn't stop loading makes me think have error in code cause such action. causes this?and how can prepare it?. feedback, comments , suggestion highly appreciated.

javascript ajax cakephp for-loop

No comments:

Post a Comment