Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Php中将Ajax结果分配给变量_Php_Ajax - Fatal编程技术网

在Php中将Ajax结果分配给变量

在Php中将Ajax结果分配给变量,php,ajax,Php,Ajax,有人能帮忙吗 我想将显示在一个div中的id=result的结果分配给一个变量,在选择一个下拉框列表并分配一个价格后,我可以使用该变量将其放入mysql数据库字段 这就是我现在拥有的 $country.onchange,函数{ 所选变量=$this.val; $results.htmlEstimated邮资:+已选择; } 显示你的下拉代码和你想显示的地方,只要指出那一行就行了。你是否编写了Ajax将值发送到PHP页面?如果不是,从这个开始。我使用一个下拉框,从mysql国家表中获取值,然后在

有人能帮忙吗

我想将显示在一个div中的id=result的结果分配给一个变量,在选择一个下拉框列表并分配一个价格后,我可以使用该变量将其放入mysql数据库字段

这就是我现在拥有的

$country.onchange,函数{ 所选变量=$this.val; $results.htmlEstimated邮资:+已选择; }
显示你的下拉代码和你想显示的地方,只要指出那一行就行了。你是否编写了Ajax将值发送到PHP页面?如果不是,从这个开始。我使用一个下拉框,从mysql国家表中获取值,然后在选择该国家后,它会获取价格。我如何将此结果回送到我可以使用的表单中的输入?$'frmelement'。vala其中frmelement是通过其属性引用表单的文本/隐藏输入id@PeterFoster莱潘托的回答让你明白了吗?你需要进一步解释吗?
<div id='result'>Abracadabra</div>
<script>
  var a = $('#result').attr('id'); // to extract the id of this div
  var b = $('#result').html();     // to extract the html content of this div
  var c = $('#result').text();     // to extract only the text from this div
  console.log('a = ', a);
  console.log('b = ', b);
  console.log('c = ', c);
</script>
$('body #result').html();