質問編集履歴

1

試したことを追加

2018/03/21 06:13

投稿

penguin520
penguin520

スコア345

test CHANGED
@@ -1 +1 @@
1
- ajaxでPOSTを飛ばすだけでは、飛ばた先PHPはないのでしょうか?
1
+ ajaxでPOSTをPHPに飛ばしている作しない
test CHANGED
@@ -319,3 +319,127 @@
319
319
  ?>
320
320
 
321
321
  ```
322
+
323
+
324
+
325
+ 下記のようなコードでは問題なく動作しました。
326
+
327
+
328
+
329
+ ```HTML
330
+
331
+ <!DOCTYPE html>
332
+
333
+ <html lang="ja">
334
+
335
+ <head>
336
+
337
+ <meta charset="utf-8" />
338
+
339
+ <title>勤怠管理β</title>
340
+
341
+
342
+
343
+ <meta name="viewport" content="width=device-width, user-scalable=yes, maximum-scale=1">
344
+
345
+
346
+
347
+ <link rel="stylesheet" href="css/csvtable.css" type="text/css" />
348
+
349
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
350
+
351
+
352
+
353
+ <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
354
+
355
+ <script type="text/javascript" src="js/jquery.csvToTable.js"></script>
356
+
357
+ <script type="text/javascript" src="js/jquery.tablesorter.min.js"></script>
358
+
359
+
360
+
361
+ </head>
362
+
363
+
364
+
365
+ <body>
366
+
367
+
368
+
369
+ <button id="button" class="button">ボタン</button>
370
+
371
+
372
+
373
+
374
+
375
+ <script>
376
+
377
+
378
+
379
+ function run(inorout){
380
+
381
+ $.ajax({
382
+
383
+ type:"POST",
384
+
385
+ url:"test.php",
386
+
387
+ data:{
388
+
389
+ 'button':2
390
+
391
+ },
392
+
393
+ success : function(j_data){
394
+
395
+ alert(j_data);
396
+
397
+ }
398
+
399
+ });
400
+
401
+ }
402
+
403
+
404
+
405
+ $('button').click(function() {
406
+
407
+ run("button");
408
+
409
+ });
410
+
411
+
412
+
413
+ </script>
414
+
415
+
416
+
417
+ </body>
418
+
419
+ </html>
420
+
421
+
422
+
423
+ ```
424
+
425
+
426
+
427
+ ```PHP
428
+
429
+ <?php
430
+
431
+
432
+
433
+ $button = $_POST{'button'};
434
+
435
+ $button = $button + 1;
436
+
437
+ touch('a.csv');
438
+
439
+ echo json_encode($button);
440
+
441
+
442
+
443
+ ?>
444
+
445
+ ```