...

View Full Version : Using prototypes Ajax parameters, how do I get ":" in the url?



BrightNail
10-07-2011, 10:47 PM
Hey, I am using prototypes (library) ajax methods and one of them is properties.

I am passing in the name value pairs:

var itemFilter = "MajorCat: Shoes",
parameters: { q : qry ,fq: itemFilter },


But when I request, it gives me this in the url:
MajorCat%3AShoes

That won't work, the search application on the backend doesn't filter properly because of the "%3A" instead of ":".

When I manually pass in via the url: MajorCat: Shoes (at the end of the query) it works.

So, that ":" is getting encoded. How do I get that IN the hash and make sure the request is unencoded when it goes out?

thanks

blaze4218
10-07-2011, 10:58 PM
you should encode before sending:

<script type="text/javascript">

var uri="my test.asp?name=ståle&car=saab";
document.write(encodeURI(uri)+ "<br />");

</script>
and decode when recieving:


<%
name = new String(decodeURI(Request("name")))
%>

BrightNail
10-07-2011, 11:01 PM
function getSearch( qry ) {
var itemFilter = "MajorCat: Shoes";
var opt = {
method: 'get',
parameters: { q : qry ,fq: itemFilter },
onSuccess: function(t) {
var data = t.responseText.evalJSON().response.docs;
// do some work
}
}
new Ajax.Request('serverpathhere/json/shoes', opt);





So, given that, how would I encode it -- but I believe the js prototype "is" encoding on its own because I am passing ":" but the url request string has the "%3A" , so I need it to be ":"

blaze4218
10-07-2011, 11:07 PM
Well, I don't know the intricacies of the library, but I would also expect it to decode... but if your saying that it didn't, try to do it manually


function getSearch( qry ) {
var itemFilter = "MajorCat: Shoes";
var opt = {
method: 'get',
parameters: { q : qry ,fq: itemFilter },
onSuccess: function(t) {
var data = t.responseText.evalJSON().response.docs;
data = decodeURI(data)
// do some work
}
}
new Ajax.Request('serverpathhere/json/shoes', opt);

but that might not work either... I might try to decode the data befor the evalJSON:



function getSearch( qry ) {
var itemFilter = "MajorCat: Shoes";
var opt = {
method: 'get',
parameters: { q : qry ,fq: itemFilter },
onSuccess: function(t) {
var data = decodeURI(t.responseText).evalJSON().response.docs;
// do some work
}
}
new Ajax.Request('serverpathhere/json/shoes', opt);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum