您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页ajax到php,jQuery AJAX发布到PHP

ajax到php,jQuery AJAX发布到PHP

来源:二三娱乐

好吧,我已经建立了我的json字符串,但是我不确定下一步该怎么做?

$('#submit').live('click',function(){

var dataString = '[';

$('#items tr').not(':first').each(function(){

var index = $('#items tr').index(this);

var supp_short_code=$(this).closest('tr').find('.supp_short_code').text();

var project_ref=$(this).closest('tr').find('.project_ref').text();

var om_part_no=$(this).closest('tr').find('.om_part_no').text();

var description=$(this).closest('tr').find('.description').text();

var cost_of_items=$(this).closest('tr').find('.cost_of_items').text();

var cost_total=$(this).closest('tr').find('.cost_total').text();

dataString += '{"row":"' + index + '", "supp_short_code":"' + supp_short_code + '", "project_ref":"' + project_ref + '", "om_part_no":"' + om_part_no + '", "description":"' + description + '", "cost_of_items":"' + cost_of_items + '", "cost_total_td":"' + cost_total + '"}';

});

dataString += ']';

$.ajax

({

type: "POST",

url: "order.php",

data: dataString,

cache: false,

success: function()

{

alert("Order Submitted");

}

});

});

在我的php文件中,我试图将dataString写入文本文件,这样我可以看到它通过ok,但是文本文件中什么都没有!我在客户端或PHP方面做错了什么,我的php代码:

$stringData = $_POST['dataString'];

$myFile = "testFile.txt";

$fh = fopen($myFile, 'w') or die("can't open file");

fwrite($fh, $stringData);

fclose($fh);

?>

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务