admin管理员组

文章数量:1310455

Using Ajax and the method GET, I am trying to send an url with brackets, but I am not getting the right encoding of them:

Request URL:http://myurl/search.html?_dc=1382510050331&search%5Bpostcode%5D=96231

instead of:

Request URL:http://myurl/search.html?_dc=1382510050331&search[postcode]=96231

Error:

Status Code:502 Host not found

Here is a snippet of my code:

Ext.Ajax.request({
    url: '/fpsearchjson.html',
    method: 'GET',
    params: {
        "geosearch[postcode]":91111
    },
    success: function(response){
        console.log("success");
    },
    failure: function(response){
        console.log("failure");
    }
});

Any help will be appreciated!

Using Ajax and the method GET, I am trying to send an url with brackets, but I am not getting the right encoding of them:

Request URL:http://myurl/search.html?_dc=1382510050331&search%5Bpostcode%5D=96231

instead of:

Request URL:http://myurl/search.html?_dc=1382510050331&search[postcode]=96231

Error:

Status Code:502 Host not found

Here is a snippet of my code:

Ext.Ajax.request({
    url: 'http://myulr.lan/fpsearchjson.html',
    method: 'GET',
    params: {
        "geosearch[postcode]":91111
    },
    success: function(response){
        console.log("success");
    },
    failure: function(response){
        console.log("failure");
    }
});

Any help will be appreciated!

Share Improve this question edited Oct 23, 2013 at 13:21 Pompeyo asked Oct 23, 2013 at 6:38 PompeyoPompeyo 1,4693 gold badges19 silver badges45 bronze badges 6
  • 1 Where is the error? %5B and %5D should decode just fine to [ and ] resp. in any web server. %xx is used for any character that needs to be encoded. – Drathier Commented Oct 23, 2013 at 6:49
  • Status Code: 502 Host not found. – Pompeyo Commented Oct 23, 2013 at 6:59
  • can you telnet to the server? telnet my.server. 80 – Drathier Commented Oct 23, 2013 at 7:00
  • You are right! the %5B and %5D decode fine. – Pompeyo Commented Oct 23, 2013 at 7:09
  • I think the dns name is wrong, or that something is messing with the request on the way to the server. Can you reach any part of the server in any way? – Drathier Commented Oct 23, 2013 at 7:16
 |  Show 1 more ment

3 Answers 3

Reset to default 6

%5B and %5D are the url-encoded values of [ and ]. This should be encoded like it is in your example.

The problem seems to be that you are unable to reach the server. Try to reach the server in any way. Maybe open the URL in your favorite browser or telnet to it: telnet my.server. 80

You need to convert your Get request though ajax should first convert to ASCII, same problem happen to me I solve it though convert my GET request into ASCII and again decode for use :)

You can use escape function to encode ,decode your url and parameter. On other side you can easily get that value in original format
for example

escape("It's me!") // result: It%27s%20me%21

本文标签: