variable result of ajax

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
lamany77
User
Posts: 144

variable result of ajax

Post by lamany77 »

dear all

i have code below :

var result = ew_Ajax("<?php echo ew_Encrypt("SELECT item FROM t_dpr WHERE no_pr = '{query_value}'") ?>", $(this).val());
// result value is : "itemx"

i try this below code :

alert(result[0]); // result is : "i"
alert(retult[1]); // result is : "t"
alert(retult[2]); // result is : "e"
alert(retult[3]); // result is : "m"
alert(retult[4]); // // result is : "x"

it's split...
how do i access the result variable for right way.
thank you


mobhar
User
Posts: 11741

Post by mobhar »

What did you mean by "access the result variable for right way"?


lamany77
User
Posts: 144

Post by lamany77 »

hi all
i have code below :

result = ew_Ajax("<?php echo ew_Encrypt("SELECT item FROM t_dpr WHERE no_pr = '{query_value}'") ?>", $(this).val());

the result is :

alert(result); \\result=item1,item2

how do i access item1 or item2 in array ...as i know result is an object.


arbei
User
Posts: 9397

Post by arbei »

From the help file:
If the result is a recordset, it is in the format of array of object. If the result is a row, it is in the format of object. If the result is a single value, it is in the format of string.

If your SQL returns only a single value, just use the result directly, e.g. alert(result).

You can view the result in your browser's console first, e.g. console.log(result).


lamany77
User
Posts: 144

Post by lamany77 »

ok thank you
and how do i convert to another data type if result is object array...
can you give me a simple example ?


Post Reply