我想从JavaScript发送一些变量和一个带POST方法的字符串.我从数据库中获取字符串,然后将其发送到PHP页面.我正在使用XMLHttpRequest对象.问题是字符串包含字符"&"几次,PHP中的$ _POST数组看起来像多个键.我尝试用"/"替换"&"和replace()函数,但似乎没有做任何事情.有人可以帮忙吗?
javascript代码和字符串如下所示:
var wysiwyg = dijit.byId("wysiwyg").get("value");
var wysiwyg_clean = wysiwyg.replace('&','\&');
var poststr = "act=save";
poststr+="&titlu="+frm.value.titlu;
poststr+="§iune="+frm.value.sectiune;
poststr+="&wysiwyg="+wysiwyg_clean;
poststr+="&id_text="+frm.value.id_text;
xmlhttp.open("POST","lista_ajax.php",true);
xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlhttp.send(poststr);
Run Code Online (Sandbox Code Playgroud)
字符串是:
<span class="style2">"Busola"</span>
Run Code Online (Sandbox Code Playgroud) 我是角度2的初学者,我想让我的第一个应用程序工作.我正在使用TypeScript.我有app.component.ts,其中我已经向另一个名为todos.component的组件发出了指令,但是我在编译时遇到以下错误:
[0] app/app.component.ts(7,3): error TS2345: Argument of type '{ moduleId: string; selector: string; directives: typeof TodosComponent[]; templateUrl: string; s ...' is not assignable to parameter of type 'Component'.
[0] Object literal may only specify known properties, and 'directives' does not exist in type 'Component'.
Run Code Online (Sandbox Code Playgroud)
我的代码是这样的:
的index.html
<html>
<head>
<title>Angular 2 QuickStart</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
<!-- 1. Load libraries -->
<!-- Polyfill(s) for older browsers -->
<script src="node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/zone.js/dist/zone.js"></script>
<script …
Run Code Online (Sandbox Code Playgroud)