문제

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

도움이 되었습니까?

해결책

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.

다른 팁

I think it is due to + sign that is getting misinterpreted when it reaches the server. I think + is being replaced by single whitespace which is creating problem in for loop. So, $x++ will be interpreted as $x (two whitespaces after $x) and it will create an infinite loop.

To get around this problem, you should probably replace all + signs in the input code with some symbol using javascript and use you own method to urldecode on server side.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top