Amit Kushwaha
Amit Kushwaha

Reputation: 101

redirecting is not working in ajax

This below script is in view/template folder.

<script>
        $(document).ready(function(){
          $("#change").click(function(){
            $.ajax({
                type: "POST",
                url: "common/customer.php",
                data: { oldemail: $("#oldemail").val(), newemail: $("#newemail").val() }
            });
          });
        });
        </script>

I want to send data in common/customer.php but it is not working. I already used ../common/customer.php but same problem. What is the solution?

Upvotes: 0

Views: 33

Answers (3)

Amit Kushwaha
Amit Kushwaha

Reputation: 101

Sorry friends problem was in my html code. I used the type of input submit but when i changed it into button then it is working fine. Thanks to all of you.

Upvotes: 0

J Kenneth
J Kenneth

Reputation: 96

According to jQuery documentation, you must declare the data type:

$.ajax({
  type: 'POST',
  url: url,
  data: data,
  success: success,
  dataType: dataType
});

TRY...

url: "/common/customer.php", // note the leading slash

Upvotes: 1

I-Kod
I-Kod

Reputation: 189

Its a absolute path problem. Your script is in view/template If your path of javascript file is like something,

view/template/myjavascript.js

And if your path of customer.php file is

view/common/

Then you must switch your directory by ../ Use

../common/customer.php

Its a relative path of your file.

Upvotes: 1

Related Questions