0

I have a bug actually with this code.

My JS code is the following:

<script>
var card_Name = "Tour Eiffel";
</script>

I send the data in ajax:

var myDatas = { card_Name: card_Name };

$.ajax({
    type: "POST",
    url: "saveContent.php",
    data: myDatas,
    cache: false,
    contentType: false,
    processData: false,
    success:  function(data){
      alert(data);
    }
}); 

In my PHP i get the element like this:

print_r($_POST['card_Name']);

But nothing is shown in the XHRs parts of my console...

Any idea why ?

Thanks.

1
  • How are you returning the result from your PHP file? Echo? Commented Sep 11, 2014 at 0:36

1 Answer 1

1

Do this in HTML or PHP File .

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
    $(function(){

        var card_Name = "Tour Eiffel";
        var myDatas = { card_Name: card_Name };

        $.ajax({
            type: "POST",
            url: "saveContent.php",
            data: myDatas,
            cache: false,
            success:  function(data){
           alert(data);
          }
       });
    })
</script>

Don't include this in your ajax

contentType: false,
processData: false,
Sign up to request clarification or add additional context in comments.

3 Comments

You would like I test your code, but I do not see any difference between your code and my question one...
You will have to explain me why those two lines make the thing? Thanks a lot!

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.