Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.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
Javascript ajax post从select标记返回从onchange事件调用的页面的整个html_Javascript_Php_Jquery_Ajax_Magento - Fatal编程技术网

Javascript ajax post从select标记返回从onchange事件调用的页面的整个html

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

我想使用ajax将一个值从js文件发布到magento中的phtml文件, 基本上,问题在于成功时,它将使用页面的html代码发出警报,从doctype开始直到结束。 我想要得到正确的值,因为我需要在通过PHP调用的magento函数中使用它

以下是我在更改时调用的函数:

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,它将默认为当前页面。我可以只将它发布到同一个页面吗?