Truyền mảng từ PHP sang JavaScript ajax

Tôi phải chuyển biến mảng Javascript sang PHP,

vì vậy tôi không thể chuyển biến mảng từ javascript sang php

Vì vậy, dưới đây là mã tôi đã cố gắng

Những gì tôi đã thử

  CSV File to HTML Table Using AJAX jQuery


    

Manage Instances

Load Data

$[ document ].ready[function[] { $[ ".button1" ].click[function[] { var val = []; $["input:checked"].each[function [index,value] { val[index] = this.value; }]; var myJSONText = JSON.stringify[val]; $.ajax[{ data: {'kvcArray': myJSONText}, url: 'Index.php', type: 'POST', success: function[data] { alert[data]; } }]; }]; }]; console.log['Debug Objects: " . json_decode[$_POST['kvcArray'], true] . "' ];"; var_dump[json_decode[$_POST['kvcArray'], true]]; die[]; } ?> $[document].ready[function[]{ $['#load_data'].click[function[]{ $.ajax[{ url:"FILES/employee.csv", dataType:"text", success:function[data] { var employee_data = data.split[/\r?\n|\r/]; var table_data = ' '; table_data += ''; for[var count = 0; count   &  link [^] encode untab case indent outdent

Preview 0

Existing Members

...or Join us

Download, Vote, Comment, Publish.

Your Email  
This email is in use. Do you need your password?
Optional Password  

When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.

This content, along with any associated source code and files, is licensed under The Code Project Open License [CPOL]



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 [416] 849-8900

Làm cách nào để chuyển mảng PHP sang JavaScript AJAX?

Chuyển mảng PHP sang JavaScript rất dễ dàng bằng cách sử dụng Ký hiệu đối tượng JavaScript[JSON]. Phương pháp 1. Sử dụng hàm json_encode[] . Hàm json_encode[] được sử dụng để trả về biểu diễn JSON của một giá trị hoặc mảng. Hàm có thể lấy cả mảng một chiều và nhiều chiều.

Làm cách nào để trả về một mảng từ phản hồi PHP thành AJAX trong JavaScript?

php $id_numbers = array['NES-ZL','NES-AL','SNS-ZL']; . '; . return $id_numbers; on the PHP side and directly translate it to a Javascript array after the AJAX call.

Làm cách nào để lấy mảng từ PHP sang jQuery?

Sử dụng json_encode[$myvalues]; . Sau đó, bạn có thể gán nó cho biến của mình. . Then you're able to assign it to your variable.

Làm cách nào để chuyển mảng đối tượng làm tham số trong bài đăng AJAX?

Tạo mảng của bạn và tuần tự hóa nó thành JSON . Gửi nó tới phương thức web của bạn . Nhận ở phía máy chủ dưới dạng chuỗi có dấu phân cách bằng dấu phẩy . Tách chuỗi và đặt các giá trị vào một mảng .

Chủ Đề