getURL, variable value

Karessa
Karessa used Ask the Experts™
on
Hi. I'm working on using LoadVars to pass some variables to a database, but in the meantime I have to use getURL().

My problem is that the format required by the Ajax agent on the other side of the url call requires the variables to be passed with the real value of the variable, not just the variable name. For example, if I have a variable like this:

myStringVar = thisIsMyString;

the getURL wants to include the string itself (thisIsMyString) instead of the variable name (myStringVar).

How do I convert the variable to its real value to be passed via the getURL?

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
What is the actual URL call look like???

CyanBlue
Commented:
So...

This one is the actual URL...
      http://url.com/admin/admaster.nsf/inCourseCreateFeedback?OpenAgent

and these are the variables that you need to pass in???
      information = 1
      informationcomments = ThisIsTheFirstSuccessfulComment=1
      learningcomments = learningCommentsText
      office = CORVALLISVariableTest
      quizselection = ThisIsAVariableTest
      reporting = 1
      reportingcomments = these%20are%20comments
      trust = 2
      trustcomments = test
      consistency = 1
      consistencycomments = These%20are%20my%20comments

I don't know what that "=1" portion is for the informationcomments variable though...  

Assuming that is just a literal...  You could try this...

CyanBlue
var lv:LoadVars = new LoadVars();
lv.information = "1";
lv.informationcomments = "ThisIsTheFirstSuccessfulComment%3D1";
lv.learningcomments = "learningCommentsText";
lv.office = "CORVALLISVariableTest";
lv.quizselection = "ThisIsAVariableTest";
lv.reporting = "1";
lv.reportingcomments = "these%20are%20comments";
lv.trust = "2";
lv.trustcomments = "test";
lv.consistency = "1";
lv.consistencycomments = "These%20are%20my%20comments";
lv.onLoad = function (ok)
{
	if (ok)
	{
		// Success
	}
	else
	{
		// Failure
	}
}
lv.sendAndLoad("http://url.com/admin/admaster.nsf/inCourseCreateFeedback%3FOpenAgent", lv, "POST"

Open in new window

Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
Wow! You've taken a lot of time for this question. Thanks!

The strings are actually set by the user via text fields and stored in the variable names. I can see how you'd be scratching your head about my previous question now because I neglected to mention that!

I was passing the test strings just to make sure I could get the data to the database on the other side.

I'm just not sure how to get the variable values in there.

Thanks again!

Author

Commented:
I wish I could accept this solution as the answer to another loadVars question, and ask the original question with the previous information so that you could have the points you deserve. I just worry that accepting the solution right now would mess up the search results for anyone who was looking for something similar. :-(

Commented:
Here is an idea since you cannot reopen that one...  Copy your question or rephrase it here so that I can see if I can answer that...  How's that???  ;)

CyanBlue

Author

Commented:
Sorry for the delay. I'm still toying with the code you provided. Because the other side demands to see the variables sent exactly like this:

&variableName = variableValue

I've changed each of the variables in the LoadVar to look something like this

lv.learningcomments = "&learningcomments = learningCommentsText";

I'll post an update in a few hours.

Thanks again for all your help!

Commented:
One thing is that those special characters that has other meaning to Flash like '&' or '=' in "&learningcomments = learningCommentsText" portion should be escaped... and even spaces to be safe...

So, that line should be written this way...
   lv.learningcomments = "%26learningcomments%20%3D%20learningCommentsText";

You might want to take a look at this page for more information on urlencoding...
   http://kb2.adobe.com/cps/141/tn_14143.html

CyanBlue

Author

Commented:
This is a great solution even though my system was incompatible with it.

Commented:
What do you mean when you said "my system was incompatible with it'???  What's not working???

CyanBlue

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial