PostDocument Function

Description

This function allows developers to cause EditLive! for XML to use HTTP POST to submit its content directly to a POST acceptor script. EditLive! for XML will also process the HTTP response. The response is processed in accordance with a parameter passed to the JavaScript method.

Syntax

JavaScript
PostDocument(strFieldName, strPostURL, strResponseProcessing, [strJSFunctionName]);

Parameters

strFieldName

This parameter is required.

The name of the field in the HTTP POST that EditLive! for XML uses to POST its content.

strPostURL

This parameter is required.

The URL for the POST acceptor script that EditLive! for XML POSTs to.

strResponseProcessing

This parameter is required.

This parameter indicates how EditLive! for XML should process the response. It has the following possible values:

  • saveToDisk

  • callback

Note

When setting this parameter to callback the strJSFunctionName must also be specified.

strJSFunctionName

This parameter is optional.

The name of the JavaScript function to be used as a callback function. The JavaScript function specified should accept the content of the HTTP response as its only parameter.

This parameter should be set in conjunction with setting the strResponseProcessing parameter to callback.

Example

Example 17.8. POSTDocument Runtime Function Example

The following code creates a button called Save on a HTML page. When the button is clicked it causes the instance of EditLive! for XML to POST its content to http://someserver/post/postacceptor.jsp in the field named editliveField. Upon receiving the HTTP response EditLive! for XML presents the user with a dialog allowing them to save the content of the response to disk. This is performed by setting the strResponseProcessing parameter to saveToDisk

<HTML>
  <HEAD>
    <TITLE>EditLive! for XML JavaScript Example</TITLE>
    <!--Include the EditLive! for XML JavaScript Library-->
    <SCRIPT src="editlivexml/editlivexml.js" language="JavaScript">
    </SCRIPT>
    </HEAD>
    <BODY>
      <FORM name = exampleForm>
        <P>Click this button to POST the document in EditLive!</P>
        <P>
          <INPUT type="button" name="button1" value="Save"                 
onClick="editlivejs.PostDocument('editliveField', 
'http://someserver/post/postacceptor.jsp', 'saveToDisk');">
        </P>
        <!--Create an instance of EditLive! for XML-->
        <SCRIPT language="JavaScript">
          <!--
          var editlivejs;               
          editlivejs = new EditLiveXML("editlive",450 , 275);
          editlivejs.setDownloadDirectory("editlivexml");
          editlivejs.setLocalDeployment(false);
          editlivejs.setConfigurationFile("sample_elconfig.xml");
          editlivejs.setDocument(escape("<P>This is EditLive!</P>"));
          editlivejs.show();
        -->
      </SCRIPT>
    </FORM>
  </BODY>
</HTML>