/    Sign up×
Community /Pin to ProfileBookmark

Passing variable

By Ajax i want to send a url and

Here is my function

[code=html]
function set_me01(kod)
{
var xml = getXhttp();
if ( !xml )
return false; //Usually you alert something but I don’t :d
var file = ‘js/script_fat.php?act=set_me01&kod=’;
xml.open(“GET”, file+kod, true);
xml.send(null);
alert(kod);
}
[/code]

Since i cannot manage to get result i added alert function at the and to see how i get kod value. To get kod value i use the following on click method

[code=html]
set_me01(‘.$row->id.’-0)
[/code]

I want the output to be something like 25-0 or 45-0 depending on $row->id value
but it doesnt work. If i change the code like

[code=html]
set_me01(‘.$row->id.’0)
[/code]

the output appears to be 450 or 170 something then as i understand, it requires a pure integer value without strings.
But i need a string variable so in this case how may i manage to get a string value as my variable kod like (12-0 or 27-0)

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@DokMar 29.2008 — You need to wrap the argument in quotes to let JS know its a string - otherwise it will assume that you are passing an expression and 25-0 = 25.

Do this
[CODE]set_me01("'.$row->id.'-0")[/CODE]
×

Success!

Help @mrtblt spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.12,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...