Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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/9/ios/109.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
使用Ajax、jQuery和API预览表单结果_Jquery_Ajax - Fatal编程技术网

使用Ajax、jQuery和API预览表单结果

使用Ajax、jQuery和API预览表单结果,jquery,ajax,Jquery,Ajax,因此,我有一个表格,客户可以为我的产品生成报价。然而,我希望他们能够预览报价成本之前,他们提交给最终确定。我有一个这样构建的API sitename.com/api/cart?model=1&height=700&width=550&cable_length=1&quantity=2&finish=polished_brass&rails=4&exit=top&concealed=0 get变量与表单元素名称相同。API只是检索一

因此,我有一个表格,客户可以为我的产品生成报价。然而,我希望他们能够预览报价成本之前,他们提交给最终确定。我有一个这样构建的API

sitename.com/api/cart?model=1&height=700&width=550&cable_length=1&quantity=2&finish=polished_brass&rails=4&exit=top&concealed=0
get变量与表单元素名称相同。API只是检索一个数字,当您单击按钮时,我想在表单旁边显示该数字


我该怎么做呢?我是Ajax新手:/

不确定您的问题是如何在链接中传递表单数据,还是如何处理返回的结果以显示它。无论如何,你可以:

$('#myform').serialize();
返回url表单中编码的表单值,然后在
jQuery.ajax()请求的url上使用该值:

$.ajax('sitename.com/api/cart?' + $('#myform').serialize(), {
    dataType: 'html',
    success: function(html) {
        // The result is an HTML page, just paste it inside the "result" div:
        $('#result').append(html);
    }
});