This section details the functions that are methods of the MMHttp object.

MMHttp.clearServerScriptsFolder()

Availability

Dreamweaver MX.

Description

Deletes the _mmServerScripts folder—and all its files—under the root folder for the current site, which can be local or remote. The _mmServerScripts folder is located in Configuration/Connections/Scripts/server-model/_mmDBScripts folder.

Arguments

serverScriptsfolder

  • The serverScriptsfolder argument is a string that names a particular folder, relative to the Configuration folder on the application server, from which you want to retrieve and clear server scripts.

Returns

An object that represents the reply from the server. The data property of this object is a string that contains the contents of the deleted scripts. If an error occurs, Dreamweaver reports it in the statusCode property of the returned object.

Example

The following code, in a menu command file inside the Configuration/Menus folder, removes all the files from the _mmServerScripts folder when it is called from a menu:

 <!-- MENU-LOCATION=NONE --> 
<html> 
<head> 
<TITLE>Clear Server Scripts</TITLE> 
<SCRIPT SRC="ClearServerScripts.js"></SCRIPT> 
<SCRIPT LANGUAGE="javascript"> 
</SCRIPT> 
<body onLoad="MMHttp.clearServerScriptsFolder()"> 
</body> 
</html>

MMHttp.clearTemp()

Description

This function deletes all the files in the Configuration/Temp folder, which is located in the Dreamweaver application folder.

Arguments

None.

Returns

Nothing.

Example

The following code, when saved in a file within the Configuration/Shutdown folder, removes all the files from the Configuration/Temp folder when the user quits Dreamweaver:

 <html> 
<head> 
<title>Clean Up Temp Files on Shutdown</title> 
</head> 
<body onLoad="MMHttp.clearTemp()"> 
</body> 
</html>

MMHttp.getFile()

Description

This function gets the file at the specified URL and saves it in the Configuration/Temp folder, which is located in the Dreamweaver application folder. Dreamweaver automatically creates subfolders that mimic the folder structure of the server; for example, if the specified file is at www.dreamcentral.com/people/index.html, Dreamweaver stores the index.html file in the People folder inside the www.dreamcentral.com folder.

Arguments

URL, {prompt}, {saveURL}, {titleBarLabel}

  • The URL argument is an absolute URL on a web server; if http:// is omitted from the URL, Dreamweaver assumes HTTP protocol.

  • The prompt argument, which is optional, is a Boolean value that specifies whether to prompt the user to save the file. If saveURL is outside the Configuration/Temp folder, a prompt value of false is ignored for security reasons.

  • The saveURL argument, which is optional, is the location on the user’s hard disk where the file should be saved, which is expressed as a file:// URL. If prompt is a true value or saveURL is outside the Configuration/Temp folder, the user can override saveURL in the Save dialog box.

  • The titleBarLabel argument, which is optional, is the label that should appear in the title bar of the Save dialog box.

Returns

An object that represents the reply from the server. The data property of this object is a string that contains the location where the file is saved, which is expressed as a file:// URL. Normally, the statusCode property of the object contains the status code that is received from the server. However, if a disk error occurs while Dreamweaver is saving the file on the local drive, the statusCode property contains an integer that represents one of the following error codes if the operation is not successful:

  • 1: Unspecified error

  • 2: File not found

  • 3: Invalid path

  • 4: Number of open files limit reached

  • 5: Access denied

  • 6: Invalid file handle

  • 7: Cannot remove current working folder

  • 8: No more folder entries

  • 9: Error setting file pointer

  • 10: Hardware error

  • 11: Sharing violation

  • 12: Lock violation

  • 13: Disk full

  • 14: End of file reached

Example

The following code gets an HTML file, saves all the files in the Configuration/Temp folder, and then opens the local copy of the HTML file in a browser:

 var httpReply = MMHttp.getFile("http://www.dreamcentral.com/people/profiles/scott.html", 
false); 
if (Boolean == 200){ 
    var saveLoc = httpReply.data; 
    dw.browseDocument(saveLoc); 
}

MMHttp.getFileCallback()

Description

This function gets the file at the specified URL, saves it in the Configuration/Temp folder inside the Dreamweaver application folder, and then calls the specified function with the request ID and reply result. When saving the file locally, Dreamweaver automatically creates subfolders that mimic the folder structure of the server; for example, if the specified file is at www.dreamcentral.com/people/index.html, Dreamweaver stores the index.html file in the People folder inside the www.dreamcentral.com folder.

Arguments

callbackFunction, URL, {prompt}, {saveURL}, {titleBarLabel}

  • The callbackFunction argument is the name of the JavaScript function to call when the HTTP request is complete.

  • The URL argument is an absolute URL on a web server; if http:// is omitted from the URL, Dreamweaver assumes HTTP protocol.

  • The prompt argument, which is optional, is a Boolean value that specifies whether to prompt the user to save the file. If saveURL argument specifies a location outside the Configuration/Temp folder, a prompt value of false is ignored for security reasons.

  • The saveURL argument, which is optional, is the location on the user’s hard disk where the file should be saved, which is expressed as a file:// URL. If prompt is a true value or saveURL is outside the Configuration/Temp folder, the user can override saveURL in the Save dialog box.

  • The titleBarLabel argument, which is optional, is the label that should appear in the title bar of the Save dialog box.

Returns

An object that represents the reply from the server. The data property of this object is a string that contains the location where the file was saved, which is expressed as a file:// URL. Normally the statusCode property of the object contains the status code that is received from the server. However, if a disk error occurs while Dreamweaver is saving the file on the local drive, the statusCode property contains an integer that represents an error code. See MMHttp.getFile() for a list of possible error codes.

MMHttp.getText()

Availability

Dreamweaver UltraDev 4, enhanced in Dreamweaver MX.

Description

Retrieves the contents of the document at the specified URL.

Arguments

URL, {serverScriptsFolder}

  • The URL argument is an absolute URL on a web server. If http:// is omitted from the URL, Dreamweaver assumes HTTP protocol.

  • The serverScriptsFolder argument is an optional string that names a particular folder—relative to the Configuration folder on the application server—from which you want to retrieve server scripts. To retrieve the scripts, Dreamweaver uses the appropriate transfer protocol (such as FTP, WebDAV, or Remote File System). Dreamweaver copies these files to the _mmServerScripts subfolder under the root folder for the current site.

If an error occurs, Dreamweaver reports it in the statusCode property of the returned object.

MMHttp.getTextCallback()

Availability

Dreamweaver UltraDev 4, enhanced in Dreamweaver MX.

Description

Retrieves the contents of the document at the specified URL and passes it to the specified function.

Arguments

callbackFunc, URL, {serverScriptsFolder}

  • The callbackFunc argument is the JavaScript function to call when the HTTP request is complete.

  • The URL argument is an absolute URL on a web server; if http:// is omitted from the URL, Dreamweaver assumes HTTP protocol.

  • The serverScriptsFolder argument is an optional string that names a particular folder—relative to the Configuration folder on the application server—from which you want to retrieve server scripts. To retrieve the scripts, Dreamweaver uses the appropriate transfer protocol (such as FTP, WebDAV, or Remote File System). Dreamweaver retrieves these files and passes them to the function that callbackFunc identifies.

If an error occurs, Dreamweaver MX reports it in the statusCode property of the returned object.

MMHttp.postText()

Availability

Dreamweaver UltraDev 4, enhanced in Dreamweaver MX.

Description

Performs an HTTP post of the specified data to the specified URL. Typically, the data associated with a post operation is form-encoded text, but it could be any type of data that the server expects to receive.

Arguments

URL, dataToPost, {contentType}, {serverScriptsFolder}

  • The URL argument is an absolute URL on a web server; if http:// is omitted from the URL, Dreamweaver assumes HTTP protocol.

  • The dataToPost argument is the data to post. If the third argument is "application/x-www-form-urlencoded" or omitted, dataToPost must be form-encoded according to section 8.2.1 of the RFC 1866 specification (available at www.faqs.org/rfcs/rfc1866.html).

  • The contentType argument, which is optional, is the content type of the data to post. If omitted, this argument defaults to "application/x-www-form-urlencoded".

  • The serverScriptsFolder argument is an optional string that names a particular folder—relative to the Configuration folder on the application server—to which you want to post the data. To post the data, Dreamweaver uses the appropriate transfer protocol (such as FTP, WebDAV, or Remote File System).

If an error occurs, Dreamweaver reports it in the statusCode property of the returned object.

Example

In the following example of an MMHttp.postText() function call, assume that a developer has placed the myScripts.cfm file in a folder named DeployScripts, which is located in the Configuration folder on the local computer:

 MMHttp.postText( 
    "http://ultraqa8/DeployScripts/myScripts.cfm", 
    "arg1=Foo", 
    "application/x-www-form-urlencoded", 
    "Configuration/DeployScripts/" 
)

When Dreamweaver executes this function call, the following sequence occurs:

  1. The myScripts.cfm file in the Configuration/DeployScripts folder on the local computer is copied to another folder named DeployScripts, which is a subfolder of the root folder on the ultraqa8 website. To deploy the files, Dreamweaver uses the protocol specified in the site configuration properties.

  2. Dreamweaver uses HTTP protocol to post the arg1=Foo data to the web server.

  3. As a result of the post request, the web server on ultraqa8 executes the myScripts.cfm script using the arg1 data.

MMHttp.postTextCallback()

Availability

Dreamweaver UltraDev 4, enhanced in Dreamweaver MX.

Description

Performs an HTTP post of the text to the specified URL and passes the reply from the server to the specified function. Typically, the data associated with a post operation is form-encoded text, but it could be any type of data that the server expects to receive.

Arguments

callbackFunc, URL, dataToPost, {contentType}, {serverScriptsFolder}

  • The callbackFunc argument is the name of the JavaScript function to call when the HTTP request is complete.

  • The URL argument is an absolute URL on a web server; if http:// is omitted from the URL, Dreamweaver assumes HTTP protocol.

  • The dataToPost argument is the data to be posted. If the third argument is "application/x-www-form-urlencoded" or omitted, data must be form-encoded according to section 8.2.1 of the RFC 1866 specification (available at www.faqs.org/rfcs/rfc1866.html).

  • The contentType argument, which is optional, is the content type of the data to be posted. If omitted, this argument defaults to "application/x-www-form-urlencoded".

  • The serverScriptsFolder argument is an optional string. It names a particular folder, relative to the Configuration folder on the application server—to which you want to post the data. To post the data, Dreamweaver uses the appropriate transfer protocol (such as FTP, WebDAV, or Remote File System). Dreamweaver retrieves these data and passes them to the function identified by callbackFunc.

If an error occurs, Dreamweaver reports it in the statusCode property of the returned object.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy