Question

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!

Was it helpful?

Solution

%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.com 80

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top