Problems encountered during DWZ usage

Source: Internet
Author: User

Problems encountered during DWZ usage

To submit a file upload form in the DWZ official document:

Because Ajax does not support enctype = "multipart/form-data", you can use the hidden iframe to handle refreshing new form submission.

<form method="post" action="url" class="pageForm required-validate" enctype="multipart/form-data"
onsubmit="return iframeCallback(this, [navTabAjaxDone/dialogAjaxDone]);">

Server Response
The DWZ-v1.2 version start server returns the same format as validateCallback:

{"StatusCode": "200", "message": "operation successful", "navTabId": "", "rel": "", "callbackType": "closeCurrent ", "forwardUrl ":""}

The first pitfall is that to upload files, the form must be processed by hiding iframe. However, the data returned by the server must be in JSON format, rather than html, therefore, the processed data cannot be displayed, but the operation status is prompted.

The second pitfall is that after the file is uploaded, it needs to be displayed after the data is analyzed on the server. So I want to display it in a pop-up window, but I found another pitfall. The problem is as follows:

Dialog link extension:

<A href = "xxx" target = "dialog" [rel = "dialogId"]>

The page to which A points will be opened in the dialog pop-up layer. rel identifies the ID of this pop-up layer, and rel is optional.

Example of Html Tag extension method:

<A href = "w_dialog.html" target = "dialog" rel = "page2"> dialog box </a> or <a href = "demo_page1.html" target = "dialog" [max = true, mask = true, maxable = true, minable = true, resizable = true, drawable = true]
Rel = "dlg_page1" title = "[custom title]" width = "800" height = "480"> open window 1 </a>

Close the window:
In the displayed window, place <button class = "close" value = "close"> </button>.

JS call method example:

$. Pdialog. open (url, dlgId, title); or $. pdialog. open (url, dlgId, title, options );

In other words, to open a pop-up window on a page, you must load a page and specify an address. Otherwise, an error will be reported... Why can't I display local data... Good design.

To display the data, you can save the result to memcache after analyzing the file data, and then return a Key to the returned json. Fortunately, you can customize the callback function, put the key in a connection and submit it through jQ simulation. The key is displayed on another page. Clean and tangle the business logic... Tears ran away...

Custom callback functions:

// Pop up the overwritten data function customAjaxDone (json) {if (json. statusCode = DWZ. statusCode. OK) {if (json. content. toString () = "xxx") {DWZ. ajaxDone (json);} else {$ ("# xxx "). attr ("href", "{wrap_url ('xxx/show_replace_data? Hash = ')} "+ json. content); $ (" # xxx "). click () ;}} else {DWZ. ajaxDone (json );}}

Form event:

onsubmit="return iframeCallback(this, customAjaxDone);"

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.