jquery - Ajax-PHP not working correctly -


the ajax-php bug has bit me again.now here's problem
send form data html php using ajax,(i'm using jquery this) , use data, play in php , give result.
ajax call made successfully, issue not data being sent php data goes missing if interpreted correctly
jquery/ajax code

$(document).ready(function(){ $("#button").click(function(e){    e.preventdefault();      var data=$("#form").serialize();        console.log(data);          $.ajax({          type:'post',         url:('php/api.php'),         data:"datastring="+data,         success: function(d){                    console.log("php response "+d);       }                  });    });   }); 

and php

<?php    $data=$_post['datastring'];    echo($data); ?> 

now here's output console

     first+name=first&last+name=second&some+detail=third&comments=fourth //output 1st          console.log() statement   php response first name=first //output php 

as can see above statement first value echoed why? mean did not recieve full value ajax?

thanks

why assigning datastring?

just add datastring without predecessor it.

$.ajax({     type:'post',     url:'php/api.php',     data:data,     success: function(d){                console.log("php response "+d);   } }); 

then in php:

<?php print_r($_post); ?> 

edit: fixed php side. thanks! unfixed though!


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -