Hi,

Try these:

Method 1:  to do it dynamically, use AJAX to get some information from the
server, for example, a $_SESSION var, or some new SVG geometry.    Here is
an example from my working code (much of which is borrowed from other folks)
which returns both text and a node (using the same data):

//This is the php document we will call to get a response
var url = ROOT_PATH + "/AJAX_php_handlers/AJAX_add_item.php?item_id=" +
connect_item_id + "&invisible=0&connect_instance=" + instance_id +
"&connect_vector=" + vector_id;

connect_item_getData(url);

function connect_item_getData(url)
    {
    //call getURL() if available, case ASV3, ASV6 and Batik
    if (window.getURL)
        {
        getURL(url,connect_item_getURLCallback);
        }

    //call XMLHttpRequest() if available, case MozillaSVG
    else if (window.XMLHttpRequest)
        {
        //this nested function is used to make XMLHttpRequest threadsafe
        //(subsequent calls would not override the state of the request and
can use the variable/object context of the parent function)
        //this idea is borrowed from
http://www.xml.com/cs/user/view/cs_msg/2815 (brockweaver)
        function XMLHttpRequestCallback()
            {
            //in this example we are only interested in the complete
transaction (readyState 4)
            if (xmlRequest.readyState == 4)
                {
                if (xmlRequest.status == 200)
                    {
                    var importedNode = document.importNode(
xmlRequest.responseXML.documentElement,true);

                    var response = xmlRequest.responseText;
                    var str_response = new String(response);

                    connect_item_addGeom(importedNode,str_response);
                    }
                }
            }
        var xmlRequest = null;
        xmlRequest = new XMLHttpRequest();
        xmlRequest.open("GET",url,true);
        xmlRequest.onreadystatechange = XMLHttpRequestCallback;
        xmlRequest.send(null);
        }
    //write an error message if either method is not available
    else
        {
        alert("your browser/svg viewer neither supports window.getURL nor
window.XMLHttpRequest!");
        }
    };


function connect_item_getURLCallback(data)
    {
    //alert("in callback " + data.success + " type " + data.contentType" + "
content " data.content);

    //check if data has a success property
    if (data.success)
        {
        var node = parseXML(data.content, document);
        var response = data.content;
        var str_response = new String(response);
        connect_item_addGeom(node,str_response);
        }
    else
        {
        alert("Something went wrong with dynamic loading of geometry!");
        }
    };


function connect_item_addGeom(node,str_response)
    {
    // append the new child node (item)
    returnValue = document.documentElement.appendChild(node);

    //Or, you can do something with str_response
    };


The php file includes some processing, and, eventually, something like this:

    //Indicate the content type of the returned data (this does not end up
in the data field of the returned info)
    header('Content-Type: text/xml');

    //and we're making svg (required for this to work in FireFox)
    echo '<g xmlns="http://www.w3.org/2000/svg";>'."\n";

    echo $new_XML_data;

    //end of xmlns group
    echo "</g>\n";

If you do not need XML data, you could use header('Content-Type:
text/html'); and just echo whatever you want to return.


Method 2:  to do it before the SVG is served,  save the svg file with
extension .php.  At the top, include <? header("Content-type:
image/svg+xml"); ?>  Then you can do php processing in the svg file before
it is served.  Including, for example onload="set_values(<? echo $a . ',' .
$b; ?>)"

Method 3:  to do it before the SVG is served, hide your info in some
invisible geometry.  For example make rectangle of id="read_me" with point
coordinate values equal to your data and opacity 0.  Then use the DOM to get
the info back again.

That's all I can think of.

Stephen



On 5/20/07, abdelhediiahmed <[EMAIL PROTECTED]> wrote:
>
>   i wish to ask if it is possible to copy the value of a variable in a
> php script in a variable of an ecma script .
> if yes how to do it?
>
>  
>


[Non-text portions of this message have been removed]



-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/svg-developers/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to