2
<div id="editproductdiv" onclick="editproduct();"> </div>


<div id="editproductform" class="modal fade" role="dialog">
  <div class="modal-dialog" style="width:1000px;">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Cancellation Reason </h4>
      </div>

      <div class="modal-body" id="editproduct" style="display:inline-block">
      </div>
      <div class="modal-footer" style="display:none;">
      </div>
    </div>

  </div>
</div>


<script>
function editproduct() {
    $('#editproductform').modal('show');
        $.ajax({
              url: 'index.php?route=order/order_details/editproduct',
            dataType: 'json',
            type: 'post',
            data: ,
            beforeSend:function(){
              $("#editproduct").html('loading');
            },
            success:function(json){
                if(json['error']){
                    // alert(json['error']);
                } else {
                    $("#editproduct").html(json['editproduct']);
                }
            }
        });
    }

</script>

Problem: when i click on the button in my view page, this alert show up : https://prnt.sc/s8gn6w

The error code :

function(e){var t,n,r,i=this[0];{if(arguments.length)return r=g(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,w(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=w.map(i,function(e){return null==e?"":e+""})),(t=w.valHooks[this.type]||w.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return(t=w.valHooks[i.type]||w.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(bt,""):null==n?"":n}}

I didn't have any alert button , but this still show up any idea why ?

3
  • can you open modal? is it the real quection? Commented Apr 30, 2020 at 8:25
  • yes can , just before the modal being open , the "alert" popup and i click ok everything went back normal Commented Apr 30, 2020 at 8:25
  • can you provide post data into index.php i mean how it gether Commented Apr 30, 2020 at 8:40

4 Answers 4

2

Problem is in your function, you missed the opening tag (. and also empty data

instead of function editproduct)

use

function editproduct()

and you need a server to run PHP files, download WAMP or XAMPP because without a server that understands PHP it just downloads the page.

Sign up to request clarification or add additional context in comments.

4 Comments

thanks for the reply , after putting () , same error
are you using a server like apache for PHP?
yeah , i do have xampp running . i have like normal register and such
@greenboxgoolu data: , is empty, you need to fix that
0

it's because missing ( or open parenthesis in you function change to

function editproduct()

Comments

0
<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>

</head>
<body>
<button id="editproductdiv" name="editproductdiv" > click here</button>


<div class="container">


  <!-- Modal -->
  <div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog">

      <!-- Modal content-->
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">Modal Header</h4>
        </div>
        <div class="modal-body">
          <p>Some text in the modal.</p>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        </div>
      </div>

    </div>
  </div>

</div>
<script>

    $(document).ready(function(){
      $("#editproductdiv").click(function(){
                 $("#myModal").modal();
      });
    });

</script>
</body>

2 Comments

Are you able to open up modal?
ajax call php not responding?
0
 <button type="button" onclick="editproduct();" name="button">button</button>


<div id="editproductform" class="modal fade" role="dialog">
  <div class="modal-dialog" style="width:1000px;">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Cancellation Reason </h4>
      </div>

      <div class="modal-body" id="editproduct" style="display:inline-block">
      </div>
      <div class="modal-footer" style="display:none;">
      </div>
    </div>

  </div>
</div>


  <script type="text/javascript">
      function editproduct(){
        //alert("ok");
         $('#editproductform').modal('show');
         $.ajax({
                     url: 'action.php',
                     dataType: 'json',
                     type: 'post',
                     data: {
                       route : 'your_route' //this you can post your every data by using comma (,)
                     },
                     beforeSend:function(){
                       $("#editproduct").html('loading');
                     },
                     success:function(json){
                       console.log(json);
                         if(json.error){
                             // alert(json['error']);
                         } else {
                             $("#editproduct").html(json.editproduct);
                         }
                     }
                 });


      }
  </script>
  </body>
</html>

I have use action.php for your php script. and think it will help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.