using ajax call to popup jquery dialog form -
i have link parameters. when click it, ajax called. when goes
action.php, have form php values(from mysql). want pop jquery
dialog.
i not sure how this.
<script> $(document).ready(function(){ $.ajax({ type: "get", url: this.href, cache:false, success: function(response){ if (response.length > 0) { document.getelementbyid('display').innerhtml=wrapperelement; wrapperelement.innerhtml = response; $( "#dialog-form" ).dialog( "open" ); } } }); }); </script>
updated codes
the body of file
<body> <div id="display"></div> echo '<a href="action.php?pldid=' . $pldid . '" class="editbt">edit</a>'; </body>
so action.php
if (isset($_get['pldid'])&& $_get['pldid']) { $form = <<<eof <form> <div id="dialog-form" title="edit fields"> <p class="validatetips">all form fields required.</p> <form> <fieldset> <label for="box">box</label> <input type='text' name='box' id='box' class="text ui-widget-content ui-corner-all" /> <label for="itemname">itemname</label> <input type='text' name='itemname' id='itemname' class="text ui-widget-content ui-corner-all" /> <label for="size">size</label> <input type='text' name='size' id='size' class="text ui-widget-content ui-corner-all" /> <label for="potency">potency</label> <input type='text' name='potency' id='potency' class="text ui-widget-content ui-corner-all" /> <label for="quantity">quantity</label> <input type='text' name='quantity' id='quantity' class="text ui-widget-content ui-corner-all" /> </fieldset> </form> </div> eof; echo $form; }
i want link open window form(values mysql). suggestion highly welcomed..thanks you..
if form not on page yet, action.php
should create markup of form, on success, append markup via innerhtml
method , show dialog.
script.php
<?php $form = ""; if (isset($_get['pldid']) && $_get['pldid']) { $form = <<<eof <form id="dialog-form"> ... </form> eof; } echo $form; ?>
markup / javascript
<div id="wrapper"> <!-- i'm wrapper. i'm waiting receive markup --> </div> <script> var wrapperelement = document.getelementbyid('wrapper'); $.ajax({ type: "get", url: this.href, cache:false, success: function(response){ if (response.length > 0) { wrapperelement.innerhtml = response; $( "#dialog-form" ).dialog( "open" ); } } }); </script>
where wrapperelement empty element in append markup generated on server-side
Comments
Post a Comment