天道酬勤,学无止境

jquery-post

jQuery, Classic ASP and SQL Server - Â being inserted before £

问题 我正在使用一个相当简单和标准的 jQuery post 将数据发布到另一个页面。 两个页面都有 <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <% Response.CharSet = "UTF-8" %> jQuery 帖子的函数部分只有alert(data) ,我返回的只是括号中的一个表单字段的值。 因此,当我添加英镑符号 ( £ ) 时,它会相应地提醒[£] 但是,我还在我发布到的页面上写入了一个文本文件,它实际上写的是£而不仅仅是£ 因此,当我进行数据库插入时,它实际上也插入£而不仅仅是£ 为什么会发生这种情况? 第 1 页 <!DOCTYPE html> <html lang="en"> <head> <title>Intelligence Point </title> <meta name="description" content=""> <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge">

2022-05-08 00:47:05    分类:技术分享    jquery   asp-classic   character-encoding   jquery-post

jQuery, Classic ASP and SQL Server - Â being inserted before £

I'm using a fairly simple and standard jQuery post to post data to another page. Both pages have <meta charset="utf-8"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <% Response.CharSet = "UTF-8" %> The function part of the jQuery post just has alert(data) and all that I return is the value of one form field enclosed in brackets. So when I add a British pound sign (£) it alerts [£] accordingly However, I also write to a text file on the page I post to and there it actually writes £ rather than just £ So when I do my database insert, it actually inserts £ as well rather

2022-05-02 05:26:01    分类:问答    jquery   asp-classic   character-encoding   jquery-post

jQuery POST 不返回可变用户(jQuery POST not returning variable users)

问题 我试图发布复选框的值,但无法这样做。 它首先收集数组中的所有复选框( selected_users - 在使用alert功能对其进行测试时工作正常),然后将它们集中发送。 但是我无法发布数据。 我得到的错误是 Key 'users' not found in . 我哪里错了? 如何在 jQuery 插件中修改我的 POST 语句? 查看.py def get_data(请求): if request.method == 'POST': selected_users = request.POST['users'] return HttpResponse(selected_users) 网址.py urlpatterns = patterns('', url(r'get_data/','apps.api.views.get_data', name = 'grabhalo_get_data'), ) jQuery $(document).ready(function(){ $('#submit').click(function() { var selected_users = $('input[type=checkbox]:checked').map(function(_, el) { return $(el).val(); }).get(); alert(selected

2021-11-11 15:47:37    分类:技术分享    jquery   django   jquery-post

jQuery POST not returning variable users

I am trying to post the values of checked boxes, but unable to do so. It first collects all the checked boxes in an array (selected_users-which is working fine upon testing it with alert function )and then sends them collectively. But I'm not able to post the data. The error that I get is Key 'users' not found in . Where i'm going wrong? how do I modify my POST statement in jQuery plugin? View.py def get_data(request): if request.method == 'POST': selected_users = request.POST['users'] return HttpResponse(selected_users) urls.py urlpatterns = patterns('', url(r'get_data/','apps.api.views.get

2021-11-11 06:56:28    分类:问答    jquery   django   jquery-post

如何在 jQuery 回发中验证模型(How to Validate a Model in a jQuery Postback)

问题 如果我有模型; Name [Required] FirstName [Required] LastName 如果我因此在我的 jQuery 回发中创建模型; Name name = new Name{ FirstName = param1, LastName = param2 }; 有没有办法可以使用装饰字段的数据注释来验证它? 这不会在视图的回发事件中发生,而是在 jQuery 回发中发生 谢谢 回答1 我假设您以 Json 格式将数据发送到控制器。 如果是,则需要使用不会干扰模型验证的自定义 JsonValueProvider。 在 ASP.NET MVC Futures 程序集中为您提供了一个,Phil Haack 写了一篇博客文章,其中包含有关如何在应用程序启动时注册它的说明。 http://haacked.com/archive/2010/04/15/sending-json-to-an-asp-net-mvc-action-method-argument.aspx

2021-10-29 15:06:18    分类:技术分享    asp.net-mvc   jquery-post

How to Validate a Model in a jQuery Postback

If I have a model; Name [Required] FirstName [Required] LastName If I create the model in my jQuery postback thus; Name name = new Name{ FirstName = param1, LastName = param2 }; Is there a way I can validate it using the data annotations that decorate the fields? This is not happening in a postback event on the view, it's happening within a jQuery postback thanks

2021-10-29 10:30:42    分类:问答    asp.net-mvc   jquery-post

PHP函数不向JQuery ajax方法返回任何数据(PHP function not returning any data to JQuery ajax method)

问题 我正在使用 jquery 的 ajax 方法将一些数据发布到服务器并取回响应。 虽然服务器端 php 代码返回一个 json 编码的字符串/数组,但响应返回为空。 有人可以指出我正在犯的错误。 下面是我使用的 jquery ajax 方法,我正在访问 postData.php 页面。 $.ajax({ url:'postData.php', type:'POST', data:data, dataType: "json", success: function(response){ console.log(response); } }); postData.php 中的内容非常简单,因为我仍在开发它。 $data = array(); //inside postData.php $data['test']=1; return json_encode($data); 它应该返回一个 json 字符串,但它返回 null。 我还尝试在 $data 数组声明之后回显一个字符串,它确实在萤火虫中回显了它,但响应是当我在成功回调上执行 console.log 时,它返回为空。 回答1 为了将结果返回到您的 ajax 函数中,您必须回显它,而不是返回,例如: $data = array(); $data['test']=1; echo json_encode($data); 回答2 这就是

2021-10-26 18:28:35    分类:技术分享    ajax   jquery   return   jquery-post

PHP function not returning any data to JQuery ajax method

I am using jquery's ajax method to post some data to the server and get back the response. Though the server side php code is returning a json encoded string/array, the response is coming back as null. Could someone point out the mistake that I am making. Below if my jquery ajax method using which I am hitting the postData.php page. $.ajax({ url:'postData.php', type:'POST', data:data, dataType: "json", success: function(response){ console.log(response); } }); The content in postData.php is pretty straight forward as I am still developing it. $data = array(); //inside postData.php $data['test']

2021-10-23 13:38:53    分类:问答    ajax   jquery   return   jquery-post

How do I get HTTP error response code in Jquery POST

I have a wrapper function used to send requests to a server, I need to do something specific if the server returns a code of 401 and I'm not sure how to get this data $.mobile.showPageLoadingMsg(); $.post(apiUrl+method,p,function(d) { $.mobile.hidePageLoadingMsg(); console.log(d.success); console.log(d.message); if(d.success == true){ window[callback](d.data); } else{ if(d.message != null){ alert(d.message); } } },'json') .error(function() { //need to check for 401 status here to do something $.mobile.hidePageLoadingMsg(); alert("error"); }); If my server side code throws a 401 exception the

2021-07-12 20:08:51    分类:问答    javascript   jquery   jquery-mobile   jquery-post

How to fail Ajax request in Rails?

When user clicks a specific item, I use jQuery's post method to update something in the database: $.post("/posts/" + post_id + "/update_something", { some_param: some_value }, success_handler); where update_something looks like this: def update_something post = Post.find(params[:id]) post.update_attributes(:some_field => params[:some_param]) render :nothing => true end The problem is if update_attributes fails, the request still succeeds and success_handler is executed. How could I cause the request to fail when update_attributes fails such that success_handler won't be executed?

2021-05-26 00:51:27    分类:问答    jquery   ruby-on-rails   ajax   ruby-on-rails-3   jquery-post