0

I am using ajax to pass php variable to javasccript function as shown below for my particular application.

i am using the foolowing function from ajax.js freely available from net to implement the ajax functionality as

var abc = new sack();

PHP portion which passes the response text:
************************************
<?
$table=$_GET;

gg($table);
gg($table)
{
echo "<a href='#' onclick='showfield($table) '>show</a>";
}

?>


javascript:
*********
showfield(ss)
{

alert(ss);
}


Problem:
*******

1] When $table is having a string with only numeric characters for eg: "123" we get the alert

2] When $table is having a string with alphanumeric characters for eg: "123efg" we get the error report as "missing ) after argument list"

3] When $table is having a string with alphanumeric characters for eg: "efg123" or "abcdfr" we get the error report as "efg123 is not defined" or "abcdfr is not defined".

7
Contributors
6
Replies
9
Views
8 Years
Discussion Span
Last Post by SatishU
0

Take a look at the generated source code, try to analyze it and you would know the answer to all your questions.

0

You need to pass strings with double or single quotes so you should use the escape character
try
echo "<a href='#' onclick='showfield(\"".$table."\") '>show</a>";

0

this solution helped me in my code thanks ;) well i was coding something else.. i was forgetting to give a quote -.- thank you so much ^^

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.