@Jony1337

Почему просто echo не работает?

Писал я код писал , всё работало и тут перестало работать , есть такой ajax запрос

<script type='text/javascript'>
$( document ).ready(function() {
    $("#btn").click(
		function(){
			sendAjaxForm('result_form', 'form1', 'ajax-half.php');
			return false; 
		}
	);
}); 
 
function sendAjaxForm(result_form, ajax_form, url) {
    jQuery.ajax({
        url:     url, 
        type:     "POST", 
        dataType: "html", 
        data: jQuery("#"+ajax_form).serialize(),  
		beforeSend: function() {
			 document.getElementById("demo").innerHTML = "<img src=\"default.gif\">";

    },
success: function(html){  
    $("#result_form").html(html);  


    	},
    	error: function(response) { 
    		document.getElementById(result_form).innerHTML = "Error.";
    	}
 	});
}
</script>

Сам ajax-half.php
<? 
 $idPoza = rand (1,99999999);
$url = 'http://example.space/teste/img.php';
$post['id-poza'] = $idPoza;
$post['nume'] = $_POST ['nume']; 
$headers = array("Content-Type:multipart/form-data"); 

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION,  TRUE); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
$data = curl_exec($ch);

curl_close($ch);

$host = 'http://example.space/teste/images/'.$idPoza.'.png';

$url = 'http://example.ru/api?upload='.$host.'';
$post['poza'] = $host; 


$headers = array("Content-Type:multipart/form-data"); 

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION,  TRUE); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 
$data = curl_exec($ch);

curl_close($ch);
$json = $data; 

json_decode($json);

$obj = json_decode($json);
$k = $obj->{'data'} -> {'img_url'}; // 12345
$poza = 'images/'.$idPoza.'.png';
unlink($poza);
$rand = rand (1,9999999999999);
$idqq = $_POST['idt']; 
echo '<script type="text/javascript">window.location.replace("http://site.space/teste/load.php?urlPoza='.$k.'&rand='.$rand.'"&idt='.$idqq.');</script>'; 




?>

На страничке должен идти редирект после получения ответа от ajax-hafl.php
Но ничего не выводить , если прописать echo "test"; то выведет "test" а строку
echo '<script type="text/javascript">window.location.replace("http://example.space/teste/load.php?urlPoza='.$k.'&rand='.$rand.'"&idt='.$idqq.');</script>';

не хочет выводить и всё
переменные $k,$rand , $idqq есть , Curl работает
Проблема только в выводе последней строки
  • Вопрос задан
  • 597 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы