2

My variables:

var strArgsString = "?Category=Customer&Year=2014";
var intModuleNo = "2";
var strOrigDashName = "Invoices"

My AJAX Post:

    var jqxhr = $.post("includes/saveParameters.asp?dname="+strOrigDashName+"&mod="+intModuleNo+"&args='"+strArgsString+"'", function() {
    alert("success");
})
.fail(function() {
    alert("error");
});

It returns a fail because the "args" value is treated as a continuation of the full query string. Im sure there will be many ways to do this but how can i get "?Category=Customer&Year=2014" treated as a string on my .asp file?

At the moment I have these

strDashboardName = Request.QueryString("dname")
intModuleNumber = Request.QueryString("mod")
strParamsArgString = Request.QueryString("args")

Any solution appreciated, but preferance given to the most efficient, thanks.

user29660
  • 90
  • 8

1 Answers1

2

I think you want to encode the args string so it can be represented as data, and not a literal continuation of the querystring.

var strArgsString = encodeURIComponent("?Category=Customer&Year=2014");
var intModuleNo = "2";
var strOrigDashName = "Invoices"

There are two additional options for encoding. encodeURI and escape. Please see Best practice: escape, or encodeURI / encodeURIComponent for further information.

Community
  • 1
  • 1
Skerkles
  • 1,123
  • 7
  • 15
  • encodeURIComponent got the desired result thanks. Sometimes you cant search for something when you dont know the solution. – user29660 Jan 30 '15 at 15:10
  • I'm sorry if I sounded like I meant you should have found the best practice prior to asking. That is NOT what I meant. I meant if you were curious about the differences that you could find the information there. I'm very familiar with the problem of search terms. =) – Skerkles Jan 30 '15 at 20:17