不工作jQuery的简单的Ajax请求

编程入门 行业动态 更新时间:2024-10-24 08:21:59
本文介绍了不工作jQuery的简单的Ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想要做的就是一个网页,并返回它的内容:

All I want to do is get a page and return the contents of it:

$.ajax({ type: "POST", url: "alg.aspx", data: sqQstring, success: function(msg) { alert("Data Saved: " + msg); } });

这不会使一个提示框,并有在错误控制台没有错误。我打印出来sqQString的价值,它等于:

This doesn't make an alert box and there are no errors in the error console. I've printed out the value of sqQString and it equals:

cc=12&cr=11&sq=10,4|10,4

我也改变了AJAX的网址为:

I've also changed the URL in the ajax to:

localhost:2728/shaper/alg.aspx

这使得一个警告框,但在它没有数据。

This makes an alert box but with no data in it.

我所访问过的页面:

localhost:2728/shaper/alg.aspx?cc=12&cr=11&sq=10,4|10,4

和它显示大量数据。

谁能帮助?

推荐答案

添加一个错误处理程序只是为了检查你没有得到一个错误返回...

Add an error handler just to check that you aren't getting an error returned...

$.ajax({ type: "POST", url: "alg.aspx", data: sqQstring, success: function(msg) { alert("Data Saved: " + msg); }, error: function (request, ajaxOptions, exception){ alert(request.status); alert(exception); } });

在此之上,使用Firefox使用Firebug和观看网络选项卡中看到实际的请求和响应。

On top of this, use Firefox with Firebug and watch the "Net" tab to see the actual request and response.

最后的意见,如果当你地址粘贴到浏览器中,做一个GET请求,而不是在你的AJAX code POST请求的工作。

Final comment, if it works when you paste the address into your browser, do a GET request rather than a POST request in your AJAX code.

根据注释可能的解决方法

$.get("localhost:2728/shaper/alg.aspx?cc=12&cr=11&sq=10,4|10,4", function (data) { alert("Data Saved: " + data); } );

您可以附加的查询字符串动态也不过试试这个首先要检查改变的例子之前,它的工作原理!

You can append that querystring dynamically also, but try this first to check it works before changing the example!

更多推荐

不工作jQuery的简单的Ajax请求

本文发布于:2023-11-24 19:53:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1626594.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:简单   工作   jQuery   Ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!