JSON jQuery PHP -


I do not understand one thing if I am using AJAX in PHP using JSON data in jQuery (key-value -Jodi), so which one should I use?

  • $ Get
  • $ Post
  • $. GetJSON

Do I need to use getJSON if I want to use json_encode in a PHP file? But if I want to send with the post (there is no postJSON )?

And one more thing:

I wrote a PHP file: / P>

   

In the jQuery file:

  $ .getJSON ("php.php", {value: "value"}, function (data) {alerts ( Data. Firstname);});  

Why does not this work?

The problem lies in the line with PHP:

  returns $ Jsonstring;  

You should echo it instead:

  $ jsonstring echo;  

The method to use the jQuery method, I suggest that $ GetJSON () If you can return the pure Jason string it depends on actually using it.

$ When using GetJSON () , your server file should return a JSON string. Thus echoing the string returned by json_encode () $. GetJSON () will be the method to take in response.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -