hi,

i have passed following parameters in ajax function, onclick = "agU(<?php echo $u . ' , ' . $msg; ?>);" its not working. when i test the same function in following way it runs fine. onclick = "agU(<?php echo $u; ?>);" am i commiting any mistake in supplying variable???
please help..

Member Avatar for diafol

hi,

i have passed following parameters in ajax function, onclick = "agU(<?php echo $u . ' , ' . $msg; ?>);" its not working. when i test the same function in following way it runs fine. onclick = "agU(<?php echo $u; ?>);" am i commiting any mistake in supplying variable???
please help..

You need to 'quote' your vars: onclick = "agU('<?=$u;?>','<?=$msg;?>');" I've used 'short tags' above - which is frowned upon [PLEEZE no more self-righteous 'I disagrees'!! IDGAD], but you can swap these for the full <?php echo $u;?> and <?php echo $msg;?> if you want.

You could also build a complete parameter string in pHp first (including quote marks) and then just include the php string - without encompassing quote marks.

From what I can see, your problem was quote marks - or should I say, the lack of them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.