tags:

views:

20

answers:

1

How I can make this:

$.ajax({
    type: "POST",
    url: "",
    data: dataString,
    cache: false,
    success: function(html){}
});

but datatype json

and using it by php

please tell me an example because i tired to search in the internet

+1  A: 

Use the dataType property to have a JSON response parsed into a native object:

$.ajax({ 
    type: "POST", 
    url: "", 
    data: dataString,
    dataType: "json",
    cache: false, 
    success: function(html){} 
});

If you're trying to post JSON data to the server, you will need json2.js to convert your object into a JSON string before posting it:

data: { json: JSON.stringify(someObj); }

and in php >=5.2:

$data = json_decode($_POST['json']);
Andy E
this great but know what is the form of php page
moustafa
@moustafa: I'm not sure I understand what you're asking. Are you asking for the php code to parse the JSON data? If so, see the bottom of my answer.
Andy E