jquery ajax php post,Jquery AJAX post to PHP

OK i've got my json string built but i'm not sure what to do next??

$('#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");

}

});

});

In my php file i was attempting to write the dataString to a text file so i could see its coming through ok but nothing was in the text file!? Am i doing something wrong client side or PHP side, my php code:

$stringData = $_POST['dataString'];

$myFile = "testFile.txt";

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

fwrite($fh, $stringData);

fclose($fh);

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值