我有一个从 atextarea
中提取的数据,如下所示:
敬启者: 兹证明 JOHN SMITH 先生/女士在 2013-2014 学年第一学期就读于该机构 作为一名二年级的心理学学生。以下是他/她的账户声明。
我试过什么?
var letter = $('#textarea_letter').val();
var myJSON = {"letter": letter };
var strJSON = JSON.stringify(myJSON);
$('#toPDF_button').attr('href', 'generate_pdf/'+ myJSON +'/pdf');
// this button then sends the letter to a function w/c generates the PDF
我得到了什么?
Error_404 页面
我需要在参数 url 中传递字母,这就是它在 url 中的样子:
localhost/accounting/generate_pdf/{"letter":"TO WHOM IT MAY CONCERN:\n\t\t\t\t\t\t\tThis is to certify that Mr/Ms JOHN S> SMITH is enrolled in this institution for this First Semester of School Year 2013-2014\n\t\t\t\t\t\t\tas a second year BSIT student. Below is his/her STATEMENT OF ACCOUNT."}/pdf
我怎么能做到这一点?我是 JSON 新手。谢谢
更新
这样做后,var myJSON = encodeURIComponent(JSON.stringify(myJSON1));
这里是新的 URL,但仍然出现相同的错误
http://localhost/accounting/accounting/generate_sta/%7B%22letter%22%3A%22TO%20WHOM%20IT%20MAY%20CONCERN%3A%5Cn%5Ct%5Ct%5Ct%5Ct%5Ct%5Ct%5CtThis%20is%20to%20certify%20that%20Mr%2FMs%20JOHN%20SMITH%20G.%20SEBUCAO%20is%20enrolled%20in%20this%20institution%20for%20this%20First%20Semester%20of%20School%20Year%202013-2014%5Cn%5Ct%5Ct%5Ct%5Ct%5Ct%5Ct%5Ctas%20a%20second%20year%20Psychology%20student.%20Below%20is%20his%2Fher%20STATEMENT%20OF%20ACCOUNT.%22%7D/pdf