小编can*_*ino的帖子

如何通过AJAX发送"&"(&符号)字符?

我想从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+="&sectiune="+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">&quot;Busola&quot;</span>
Run Code Online (Sandbox Code Playgroud)

javascript string ajax post xmlhttprequest

85
推荐指数
4
解决办法
14万
查看次数

Angular 2组件指令不起作用

我是角度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)

javascript typescript angular

25
推荐指数
1
解决办法
5万
查看次数

标签 统计

javascript ×2

ajax ×1

angular ×1

post ×1

string ×1

typescript ×1

xmlhttprequest ×1