Ajax Refresh of Div on form submit oscommerce

情到浓时终转凉″ 提交于 2019-12-13 12:46:45

问题


In oscommerce I want to refresh the product div called 'left-div' with form field checked results on autosubmit- rather than whole page:- I use oscommerce 2.3.4:- Step wise I have below files- I have pulled a form on index.php in a div called 'right-div', which is called from a box module bm_form.php using below code-

    if (class_exists(bm_form)) {
$boxdata = new bm_form;
echo $boxdata->getData();
}

Now this form has below code for action on bm_form.php:-

<form name="form_srch" id="form_srch" action="'.tep_href_link(FILENAME_DEFAULT).'" method="get" >.....</form>

The form is processed at this folder

 ext/form/form.php
 ext/form/form.js
 ext/form/form.css

The above form process is called in my index.php using below code:- at very top

require('includes/application_top.php');
   require('ext/form/form.php');

The issue is I when I fill the form it triggers the entire page to refresh whereas I need to refresh only the div with form result.

My form.js uses below code for submit

 $("#form_srch").submit();  // submit form

I tried using the idea given here for ajax refresh of Div- Refreshing ajax div with form data

Editing this code in ext/form/form.js:-

 $("#form_srch").submit(
            function(e){
          e.preventDefault();
            $.get('ext/form/form.php', $(this).serialize(), function(data){
                $('#left-div').html(data);
            }
);            

           return false;
});  // submit form

And removed the action part from the form leaving action=""

But still it does not work at all the form stops working altogether, Please can someone help me get this working......

来源:https://stackoverflow.com/questions/33340469/ajax-refresh-of-div-on-form-submit-oscommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!