php - AJAX only returning first character of variable -
The output from the following script is follow.php When you do this: Since they are string, gives PHP the index of the If you use: You will see: 1H , while I expect it to be
1hello < / code>.
var id = "1"; var shop_name = "hello"; $ .ajax ({type: "post", url: "http://www.domain.com/includes/follow.php", data: {shop_name: shop_name, id: id}, success: function (data) { Console.log (data);}});
$ id = $ _POST ['id']; $ shop_name = $ _POST ['store_name']; Echo $ id ['id']; Per echo $ shop_name ['shop_name']; ? & Gt; You are assigning frequencies as strings to them, not indexed for other associative array. Just use:
$ id echo; Echo $ shop_name;
$ id ['id'] echo; Per echo $ shop_name ['shop_name'];
[0] string, which for
1 is
$ id
$ shop_name for and
h .
error_reporting (E_ALL); Ini_set ('display_errors', '1');
Warning: illegal string offset 'id' in follow.php on line 5 1 warning: Invalid string offset line in 'shop_name' 6h follow.php
Comments
Post a Comment