Tag: url encoding

jQuery的$ .ajax URL编码问题

我正在使用jQuery的$ .ajax方法向REST服务发送和检索数据。 我提供给$ .ajax方法的一些URL需要空格和其他特殊字符进行编码。 问题在于Chrome,Safari(Webkit)和Internet Explorer浏览器。 Firefox POST是一个URL,它被编码但其他浏览器POST到一个未编码的URL。 举个例子: $.ajax ({ url: “http://localhost:8080/rest/123/Product Line A/[Product Type B]”, type: “POST”, dataType: “json”, data: { … }, success: function(…){}, error: function(…){} }) Firefox以下列格式发布URL: http://localhost:8080/rest/123/Product%20Line%20A/%5BProduct%20Type%20B%5D Chrome,Safari和IE按以下格式发送url: http://localhost:8080/rest/123/Product Line A/[Product Type B] REST服务接受编码(Firefox)格式 – 有没有一种方法可以使所有浏览器保持一致? 提前致谢!