S
S
stsashko_user2014-12-09 15:32:24
PHP
stsashko_user, 2014-12-09 15:32:24

$.ajax via GET not working on all versions of Internet Explorer?

Friends help me with this problem.
There is a code on the client side
That is, I pass the GET str parameter via AJAX

var str = 'тест';
    $.ajax({
       url: 'http://' + window.location.host + '/search/test',
       type : 'GET',
       data: 'str=' + str,
       dataType: "json",
       success: function(res){
        console.log(res);
      }
    });


I accept ajax on the server side
class Search extends MY_Controller {
public function test()
    {
        echo json_encode($_GET);
    }
}


As a result, in Internet Explorer on the server side, the $_GET['str'] array is empty. That is, the value is not passed through AJAX.
The funny thing is that a value is passed through POST.
That is, it works like this:
var str = 'тест';
    $.ajax({
       url: 'http://' + window.location.host + '/search/test',
       type : 'POST',
       data: 'str=' + str,
       dataType: "json",
       success: function(res){
        console.log(res);
      }
    });

class Search extends MY_Controller {
public function test()
    {
        echo json_encode($_POST);
    }
}


How can this issue be resolved?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Taratin, 2014-12-09
@stsashko_user

And if you just try

var str = 'тест';
    $.ajax({
       url: 'http://' + window.location.host + '/search/test?str='+encodeURIComponent(str),
       type : 'GET',
       dataType: "json",
       success: function(res){
        console.log(res);
      }
    });

M
mayorovp, 2014-12-09
@mayorovp

I apologize for the empty nit-picking, but why didn't you write url: '/search/test'? Where does this love for absolute references come from, where you can do without them?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question