working example with json 2 files first index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <title> malsup jquery form to php </title> <script type="text/javascript" src=" http://www.malsup.com/jquery/jquery-1.2.6.js"></script> <script type="text/javascript" src=" http://www.malsup.com/jquery/form/jquery.form.js"></script> <script type="text/javascript"> // wait for the DOM to be loaded $(document).ready(function() { // bind 'myForm' and provide a simple callback function $('#myForm').submit(function() { // submit the form $(this).ajaxSubmit({ // dataType identifies the expected content type of the server response 'dataType': 'json', // success identifies the function to invoke when the server response // has been received 'success': function (data) { msgText = '<p>Thank You ' + data.myName + '</p>'; $('#msg').html(msgText); } }); return false; }); }); </script> </head> <body> <div id="msg"></div> <form action="test.php" id="myForm" method="get"> name <input type="" value="" name="myName" /> <input type="submit" value="say hello to yourself" /> </form> </body> </html> ------------------------------ test.php <?php // test.php $response = Array("myName" => $_GET['myName'], "success" => 1); echo json_encode($response); ?> as I say I don't know how to implement it in drupal - all the info you need is at that link (with that and drupal docs) 2008/11/10 bharani kumar <[EMAIL PROTECTED]> > Hi here is my module, i want to add the JQuery into this module, > > that is form submit without page refresh , > > 2008/11/10 bharani kumar <[EMAIL PROTECTED]> > >> I thing confusing you, >> >> I tel what i want ? >> >> I want to submit form without page refresh, >> >> Is there any best link other then wha u given last, >> >> One more thing am having some script, >> >> >> But am expecting help is, i want to implement into drupal,,, >> >> >> >> 2008/11/10 Sam Sherlock <[EMAIL PROTECTED]> >> >> I think we are misunderstand each other a bit >>> >>> I asked to see you html - I saw the example and the form is not submitted >>> by ajax >>> >>> I was asking if your form has an id of myForm eg >>> >>> <form id="myForm"> >>> >>> would also be helpful if you could post link to example does not store >>> ip's after submitting >>> >>> >>> 2008/11/10 bharani kumar <[EMAIL PROTECTED]> >>> >>>> Hi u see , in that page is loading / redirecting know, >>>> >>>> But my thing is without page reloading to submit the form, >>>> >>>> >>>> Got my point , one more thing , am having some jquery script , which >>>> working fine (without page refresh to form submiting) >>>> >>>> But i need the help in, i want to use the jquery in Drupal, >>>> >>>> >>>> On Mon, Nov 10, 2008 at 7:18 PM, Sam Sherlock <[EMAIL PROTECTED]>wrote: >>>> >>>>> whats the html - I saw the link and that form did not appear to have >>>>> the event applied to the form >>>>> >>>>> perhaps this could be solved by checking that the id of the form is >>>>> myForm. I know nothing of drupal >>>>> >>>>> I can check back to the link since its logged my ip and now tells me I >>>>> have already voted visit the site etc >>>>> >>>>> 2008/11/10 bharani kumar <[EMAIL PROTECTED]> >>>>> >>>>> But , i want to implement in Drupal , >>>>>> >>>>>> Am not sure the below code correct, >>>>>> >>>>>> In this i want to add the JQuery, >>>>>> >>>>>> <?php >>>>>> >>>>>> function custom3_block($op='list',$delta=0){ >>>>>> >>>>>> switch($op){ >>>>>> >>>>>> case 'list': >>>>>> $blocks[0]['info'] = t('Custom 3'); >>>>>> return $blocks; >>>>>> >>>>>> case 'view': >>>>>> >>>>>> $output[] =t("Bharanikumar"); >>>>>> $output[].=drupal_get_form('myForm'); >>>>>> $output[] .=' <script type="text/javascript"> >>>>>> // wait for the DOM to be loaded >>>>>> $(document).ready(function() { alert("Tets") >>>>>> $("#myForm").ajaxForm(function() { >>>>>> alert("Thank you for your comment!"); >>>>>> }); >>>>>> }); >>>>>> </script>'; >>>>>> >>>>>> >>>>>> $block['content']=theme('hotelsearch_item_list',$output); >>>>>> >>>>>> >>>>>> return $block; >>>>>> >>>>>> >>>>>> } >>>>>> >>>>>> } >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> function myForm(){ >>>>>> >>>>>> $modpath = drupal_get_path('module','custom3'); >>>>>> drupal_add_js($modpath . '/jquery-1.2.6.js','module'); >>>>>> //$form['#action']=url('comment.php'); >>>>>> >>>>>> $form['name']=array( >>>>>> '#type' => 'textfield', >>>>>> '#title' => t('name') >>>>>> ); >>>>>> $form['comment'] = array( >>>>>> '#type' => 'textarea', >>>>>> '#title' => t('comment'), >>>>>> '#required' => TRUE >>>>>> ); >>>>>> $form['submit'] = array( >>>>>> '#input' => TRUE, >>>>>> '#name' => 'op', >>>>>> '#type' => 'submit', >>>>>> '#submit' => TRUE, >>>>>> '#value' =>t('submit') >>>>>> ); >>>>>> return $form; >>>>>> >>>>>> } >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Mon, Nov 10, 2008 at 6:19 PM, Sam Sherlock <[EMAIL PROTECTED] >>>>>> > wrote: >>>>>> >>>>>>> this should be your solution >>>>>>> >>>>>>> http://www.malsup.com/jquery/form/ >>>>>>> >>>>>>> 2008/11/10 [EMAIL PROTECTED] < >>>>>>> [EMAIL PROTECTED]> >>>>>>> >>>>>>> >>>>>>>> Hi Friends >>>>>>>> >>>>>>>> I just want to submit the form without page refresh i want to do >>>>>>>> this >>>>>>>> using j query, >>>>>>>> >>>>>>>> >>>>>>>> Am actually working in DRUPAL ,Tell me how to implement this in >>>>>>>> drupal, >>>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> உங்கள் நண்பன் >>>>>> பரணி குமார் >>>>>> >>>>>> Regards >>>>>> B.S.Bharanikumar >>>>>> >>>>>> POST YOUR OPINION >>>>>> http://bharanikumariyer.hyperphp.com/ >>>>>> >>>>> >>>>> >>>> >>>> >>>> -- >>>> உங்கள் நண்பன் >>>> பரணி குமார் >>>> >>>> Regards >>>> B.S.Bharanikumar >>>> >>>> POST YOUR OPINION >>>> http://bharanikumariyer.hyperphp.com/ >>>> >>> >>> >> >> >> -- >> உங்கள் நண்பன் >> பரணி குமார் >> >> Regards >> B.S.Bharanikumar >> >> POST YOUR OPINION >> http://bharanikumariyer.hyperphp.com/ >> > > > > -- > உங்கள் நண்பன் > பரணி குமார் > > Regards > B.S.Bharanikumar > > POST YOUR OPINION > http://bharanikumariyer.hyperphp.com/ >