Javascript ajax post从select标记返回从onchange事件调用的页面的整个html
我想使用ajax将一个值从js文件发布到magento中的phtml文件, 基本上,问题在于成功时,它将使用页面的html代码发出警报,从doctype开始直到结束。 我想要得到正确的值,因为我需要在通过PHP调用的magento函数中使用它 以下是我在更改时调用的函数:Javascript ajax post从select标记返回从onchange事件调用的页面的整个html,javascript,php,jquery,ajax,magento,Javascript,Php,Jquery,Ajax,Magento,我想使用ajax将一个值从js文件发布到magento中的phtml文件, 基本上,问题在于成功时,它将使用页面的html代码发出警报,从doctype开始直到结束。 我想要得到正确的值,因为我需要在通过PHP调用的magento函数中使用它 以下是我在更改时调用的函数: function getsingproduct(id) { var str = 'product' + id; var currentselecteditem; ele = document.getElementById("p
function getsingproduct(id)
{
var str = 'product' + id;
var currentselecteditem;
ele = document.getElementById("product" + id);
currentselecteditem = ele.options[ele.selectedIndex].value;
jQuery.ajax({
type: 'post',
data: {
curr_item: currentselecteditem
},
success: function (data) {
jQuery('#testing').text(data);
alert('data ' + data);
},
});
}
下面是一些javascript代码:
$.ajax({
type:"POST",
url: "new_prob_submit.php",
data: {
curr_item: currentselecteditem
},
dataType: "json",
success:function(data){
alert(data);
}
});```
你在哪里发布数据?没有设置URL!!我想把它发布到同一个页面,这就是为什么,我想如果我不使用url,它将默认为当前页面。我可以只将它发布到同一个页面吗?