简体   繁体   中英

How do I create a popup to submit form data?

I did see this post which lead me to the UI/API/1.8/Dialog

I'm looking for the most basic popup to submit form data. Is this it? (does a popup submitting form data have to use ajax?)

Thank You.

EDIT - Sorry, to clarify, I mean that the popup contains the actual input fields and the Submit button as well.
I did see the jQuery example for this but it includes many .js files to implement. I'm looking for the "lightest" most basic popup to input to and send name/value paisr to the server.

Create an html form and use jquery to post/submit

http://jquery.malsup.com/form/

http://api.jquery.com/jQuery.post/

edit: You can do it simply in one .js file. All you need to do is add an .htm form to your project add the input fields you want.. Then reference those fields in your .js.

for example, this is the html form:

<table>
  <td><input type="text" maxlength="50" id="EditUserFName" style="width:220px;" /></td>
     </tr>  
 <tr>
      <td>Last Name:</td>
      <td><input type="text" maxlength="50" id="EditUserLName" style="width:220px;" /></td> 
 </tr>
</table>

your .js file...

function CallService(method, jsonParameters, successCallback, errorCallback){
if (errorCallback == undefined)
{
    errorCallback = function(xhr)
    {
        if (xhr.status == 501)
        {
            alert(xhr.statusText);
        }
        else
        {
            alert("Unexpected Error");
        }
    }
}

$.ajax({
    type: "POST",
    url: method,
    data: jsonParameters,
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: successCallback,
    error: errorCallback
});}


function SaveEvent(onSaveCallback){
var fName = $("#EditUserFName").val()
var lName = $("#EditUserLName").val(),

CallService("ServiceLayer/Manager.asmx/SaveEvent", JSON.stringify(fName, lName), function()
{       
    if (onSaveCallback != undefined)
    {
        onSaveCallback();
    }        
}}

that's the basics of how to do it.. obviously you need some validation and some other functions

Try prototype based popup windows 
http://livepipe.net/

Traditionally popup used to submit data using AJax. but i worked in project where i load popup using Ajax but submitting of data to server is mere none ajax

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM