关于form表单,ajax和$http传输数据

1,使用form表单提交数据时会跳转页面,即会将整个页面提交刷新,而ajax和$http和php进行数据交互只是页面的部分更新;

ajax可以进行同步传输,即async="false",$http只能进行异步通讯;

2,from表单与php交互:

<form  action="new.php" >

<input  type="text">

<input  type="submit">

</form>

3,ajax与php交互上传内容:

var  ajax=new  XMLHttpRequest();

ajax.open("get","new.php", true);

ajax.send();

扫描二维码关注公众号,回复: 3781314 查看本文章

$("input").val(responseText);

4,$http与php交互:

var  app=angular.module("my",[ ]);

app.constroller("hello",function($scope,$http){

$http.get("new.php").then(function(txt){

$scope.name=txt.data;})

})

猜你喜欢

转载自blog.csdn.net/kalinux/article/details/83211054