php - AJAX only returning first character of variable -


The output from the following script is 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);}});   

follow.php

  $ 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;   

When you do this: $ id ['id'] echo; Per echo $ shop_name ['shop_name'];

Since they are string, gives PHP the index of the [0] string, which for 1 is $ id $ shop_name for and h .

If you use:

  error_reporting (E_ALL); Ini_set ('display_errors', '1');   

You will see:

  Warning: illegal string offset 'id' in follow.php on line 5 1 warning: Invalid string offset line in 'shop_name' 6h     follow.php

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -