Search code examples
phpjqueryajaxcallbackcodemirror

How to tackle infinite loop?


Hi all here you can check my previous question - Ajax call back not called. How to tackle this? please check and see here my code of execute.php where the code of editor is goes and run and suggest me why for loop goes to infinite loop.

here is my code of code1.js by that i am fetch code of editor and run through exec.php

$.ajax({
    type: 'GET',
    url: 'exec.php',
    data: code,
    success: function(data) 
    {
        alert(data);
        $(loader).addClass("hidden");
        var stdout = $(form).children('.stdout');
        if (data.search("Parse error")>0)
        {
            var str = data.replace("<b>Parse error</b>:  ","");
        $(stdout).html(str);
        $(stdout).removeClass('hidden');    
        }   
        else
        {
            $(stdout).html(data);
            $(stdout).removeClass('hidden');
        }   
    },
    error: function(req, status, err) {
        alert(status);
        alert(err);
    },
    dataType: 'JSONP'
});

when i am insert the code of for loop in editor its goes to infinite loop like

"; } ?>

you can check this issue at web.guru99.com

Please help


Solution

  • Insteading of posting the PHP code through the url, you can post it as additional data. That solves your encoding issues, and it allows you to send larger chunks of code as well.