stupid concatenating string question

D

dewed

I'm a total javascript newb, despite being able to pull off some ajax
stuff here & there, I don't get some of the simplest basics.. such as
concatenating strings..

This is what I'm trying to do .....

httpObject.open("GET", './gen-project-list.php?
userid='+document.getElementById('authuserid').value,true
+'&client='+document.getElementById('client').value, true);


I'm just trying to set the URL to include ?
userid=X&client=X .. I am seeing the userid value passed, but
&client=X doesn't seem to be in the request...

Could someone hit me upside the head with a gentle hint please..
thanks.

Dewed
 
S

SAM

Le 11/24/08 9:27 PM, dewed a écrit :
I'm a total javascript newb, despite being able to pull off some ajax
stuff here & there, I don't get some of the simplest basics.. such as
concatenating strings..

This is what I'm trying to do .....

httpObject.open("GET", './gen-project-list.php?
userid='+document.getElementById('authuserid').value,true
+'&client='+document.getElementById('client').value, true);


I'm just trying to set the URL to include ?
userid=X&client=X .. I am seeing the userid value passed, but
&client=X doesn't seem to be in the request...

of course : you introduced the argument 'true' before the end.

You've made :

httpObject.open("GET", url+id, true, clientzoinzoin, re true);
^^^^^^^^^^^^^^^^^^^^^^^^^^^ ignored


httpObject.open("GET",
'./gen-project-list.php?userid=' +
document.getElementById('authuserid').value +
'&client=' + document.getElementById('client').value,
true);

or :

var url = './gen-project-list.php' +
'?userid=' + document.getElementById('authuserid').value +
'&client=' + document.getElementById('client').value;
httpObject.open("GET", url, true);
 
D

dewed

Thank you so much for your time !

You are exactly correct and thanks to you it works I guess I hadn't
realized that "true" was actually a parameter for the
httpObject.open function.. adding that the growing list of my
javascript shortcomings
 
T

Thomas 'PointedEars' Lahn

dewed said:
I'm a total javascript newb, despite being able to pull off some ajax
stuff here & there,

That's a really bad idea.
I don't get some of the simplest basics..
such as concatenating strings..
See?

This is what I'm trying to do .....

Your dot key seems to be somewhat borken.
httpObject.open("GET", './gen-project-list.php?
userid='+document.getElementById('authuserid').value,true ^^^^^
+'&client='+document.getElementById('client').value, true);

There is one extra ",true" (supposedly due to copy-and-pray) which causes
"true+'...'" to be regarded the third argument of the open() call, and
`true' the (AFAIK not specified) fourth as becomes obvious when written as
parsed:

httpObject.open(
"GET",

'./gen-project-list.php?userid='
+ document.getElementById('authuserid').value,

true
+ '&client='
+ document.getElementById('client').value,

true
);

Since `true' is implicitly type-converted to string as "true", the
third argument is not `true', and so the request is maybe not handled
asynchronously (the fact aside that it uses the wrong URI).

You have also "forgotten" to escape the URI components with
encodeURIComponent() as follows:

httpObject.open(
"GET",
'./gen-project-list.php?userid='
+ encodeURIComponent(document.getElementById('authuserid').value)
+ '&client='
+ encodeURIComponent(document.getElementById('client').value),
true);

BTW, you can lose the "./".

And you should not need document.getElementById() here because the data
should come from a form which is represented by an object that has an
`elements' property to refer to a collection of the represented controls
of that form.
I'm just trying to set the URL to include ?
userid=X&client=X .. I am seeing the userid value passed, but
&client=X doesn't seem to be in the request...

BAD. Borken as designed.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top