Jump to content

AJAX HELP NEW


fareedreg

Recommended Posts

follow this belwo mentioned url ... in this topic you pass a string and get back upper case string. If i want uppercase and reverse of string ... then how can we get back values of two variable seperately. I just want to know that If I have more than  one value getting back... how its possible..

 

 

http://www.ajaxf1.com/tutorial/ajax-php.html?page=3

Link to comment
https://forums.phpfreaks.com/topic/186083-ajax-help-new/
Share on other sites

You could return an array encoded using PHP's json_encode. The "httpObject.responseText" property would then contain the JSON encoded array that you can access easily with JavaScript. For example:

 

if (isset($_GET['inputText'])
{
    $return = array(
        strtoupper($_GET['inputText']),
        strrev($_GET['inputText']) // I assume this is what you meant by 'reverse of string'?
    );
    echo json_encode($return);
}

 

(...)

var response = httpObject.responseText;

alert('Uppercase: ' + response[0] + ' Reversed: ' + response[1]);

 

Not tested but the logic's right.

Link to comment
https://forums.phpfreaks.com/topic/186083-ajax-help-new/#findComment-983670
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.