Pergunta

I'm getting a headache trying to parse an MDX member from a $.get request through to a .asmx file;

initially my request looked like this; $.get("/" + source + ".asmx/FilterData", {strKeyval: queryName, controlID: currentID, filterString: filterString},

where filterString's value is; [Product].[Product].[Dept No].&[123]

I was getting a server side error though and figured it was the ampersand, so on the advice of Rory in this question, I tried the escape() function, but now I'm getting this error from the asmx file, because of the % symbols;

Parser: The following syntax error occurred during parsing: Invalid token, Line 1, offset 499, %

how do I make asp accept this? I never have this problem with php!

Foi útil?

Solução 2

Ok, so after tearing and wrecking my brain, I found a simpler solution than I'd have thought would have worked:

I removed the escape() function entirely as well as any serialization I used before and simply replaced the &s with html encoded ampersands like this;

filterString = filterString.replace("&", "\\u0026");

works nicely, I wish ASP and Microsoft would stop being so anal, they should deal with security risks rather than avoid it

Outras dicas

You can configure your asmx service to accept POST requests:

In web.config:

<webServices>
    <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
    </protocols>
</webServices>

And instead of $.get use $.post. If use post the data will be sent in the request's body and you won't need to escape the '&'

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top