对于javascript–jQuery$().css(“content”)在IE9中返回字符串“normal”感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍jquery返回值,并为您提供关于a
对于javascript – jQuery $().css(“content”)在IE9中返回字符串“normal”感兴趣的读者,本文将会是一篇不错的选择,我们将详细介绍jquery返回值,并为您提供关于asp.net – 在Internet Explorer 8中使用ScriptManager.RegisterClientScriptBlock和jQuery时出现问题、c# – jQuery:在jquery ajax json调用中返回字符串响应、javascript - post上传完 返回format: request Content-Type isn''t multipart/form-data、javascript – Ajax调用在CodeIgniter中返回int而不是字符串的有用信息。
本文目录一览:- javascript – jQuery $().css(“content”)在IE9中返回字符串“normal”(jquery返回值)
- asp.net – 在Internet Explorer 8中使用ScriptManager.RegisterClientScriptBlock和jQuery时出现问题
- c# – jQuery:在jquery ajax json调用中返回字符串响应
- javascript - post上传完 返回format: request Content-Type isn''t multipart/form-data
- javascript – Ajax调用在CodeIgniter中返回int而不是字符串
javascript – jQuery $().css(“content”)在IE9中返回字符串“normal”(jquery返回值)
我正在使用CSS内容属性将一些值从我的LESS样式表传递给JavaScript(使用Canvas元素中的LESS中定义的一些颜色).
为了让我的生活更轻松,我决定以简单的方式放置这些值,以便在JavaScript中解析它们.
少量代码:
div#colorChart-critical {
content:'@{critical-highest},@{critical-veryhigh},@{critical-high},@{critical-low},@{critical-medium},@{critical-verylow}';
}
编译时带来以下CSS:
div#colorChart-critical6 {
content: '#ff0000,#ff7200,#fffc00,#0000ff,#a200ff,#00ff00';
}
然后我尝试使用jQuery读取它们:
$("div#colorChart-critical").css("content").split(",");
问题是在IE9中调用$(“div#colorChart-critical”).css(“content”)由于某种原因返回字符串“normal”. Opera,Firefox,Safari和Chrome工作正常.
为什么会在IE9中发生这种情况?
在IE9上解决这个问题?如果不是任何其他CSS属性我可以随机文本?
我可以使用类似的东西:
background: url(#ff0000,#00ff00);
但这会在控制台上产生错误.
我不知道为什么其他浏览器会返回你定义的值,特别是考虑到.css()
makes use of getComputedStyle()
on those browsers.如果他们正在实现CSS2.1内容,那么他们违反了CSS2.1而没有将值计算为正常值.如果他们正在准备一个晚期的CSS3实现,无论可能是什么,那么它们在某种程度上在实际元素上实现它是有道理的……无论如何都要羞辱它们.
这让我想到另一点:如果你实际上并没有尝试使用CSS来修改元素的内容,那么就不要使用内容,即使它没有定义用于元素的事实是你正在制作的原因首先使用这种技术.您可以尝试将这些颜色分配给某些类,创建隐藏元素并查询该元素的颜色样式.
asp.net – 在Internet Explorer 8中使用ScriptManager.RegisterClientScriptBlock和jQuery时出现问题
ScriptManager.RegisterClientScriptBlock(this,typeof(Page),Guid.NewGuid().ToString(),"$.jGrowl('" + message + "');",true);
该代码在Firefox / Chrome / Safari中非常完美.但是在Internet Explorer中我没有看到通知,我没有收到任何Javascript错误.
我在Windows 7下工作,我有Internet Explorer 8 Beta(版本8.0.7000.0),我在兼容模式下有相同的“错误”.
我怎么解决这个问题?
解决方法
为了解决这个问题,我只修改了你的脚本,以便在文档准备好后调用jGrowl.这是更新的代码:
ScriptManager.RegisterClientScriptBlock(this,"$(function(){$.jGrowl('" + message + "');});",true);
c# – jQuery:在jquery ajax json调用中返回字符串响应
在我的处理程序代码中,我想以字符串格式返回html表.这是我的处理程序代码的快照
context.Response.ContentType = "text/plain"; context.Response.Write(sResponse);
其中sResponse包含< table>< tr>< td> PropertyName< / td>< td> PropertyID< / td>< / tr>< tr>< td> abc< / td>< td> 1 LT; / TD>< / TR>< /表>
我的jquery代码(检查错误函数中的内联注释):
id = { 'PropertyID': id }; $.ajax("Handlers/GenericHandler.ashx?Type=getProperties",{ type: 'post',dataType: 'json',cache: false,contentType: "application/json",data: JSON.stringify(id),success: function (data) { console.log(data); },error: function (xhr,status) { console.log(status); // Output as parseError console.log(xhr.responseText); // My sResponse string ! But Why Here ? } });
我的问题 :
>为什么我没有得到成功功能的回应
>这是正确的方法吗?或者我应该将html表转换为json对象然后返回它.并再次以表格格式显示它?
解决方法
如果站点的其余部分使用JSON作为传输格式,则将HTML包装为JSON对象并将其返回.
在您的后端代码中,返回看起来像这样的内容
{response_html : "<table><tr><td>PropertyName</td><td>PropertyID</td></tr><tr><td>abc</td><td>1</td></tr></table>"}
在您的jQUery代码中,您可以在成功回调中访问它.
success: function (data) { console.log(data.response_html); },
注意 – 您需要从后端代码中删除纯文本内容类型并制作该JSON.
javascript - post上传完 返回format: request Content-Type isn''t multipart/form-data
post上传mp3完 返回错误文本是这个
{"error":"invalid multipart format: request content-type isn''t multipart/form-data"}
这是哪里的错误 好像说的是说:内容类型不是multipart/form-data”的意思
回复内容:
post上传mp3完 返回错误文本是这个
{"error":"invalid multipart format: request content-type isn''t multipart/form-data"}
这是哪里的错误 好像说的是说:内容类型不是multipart/form-data”的意思
你在包头没有写入content-type类型。 建议抓下包看下,或是用浏览器的调试模式看下
立即学习“Java免费学习笔记(深入)”;
上传文件要指定Content-Type,比如php用curl上传文件
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);$data 需要为数组,而不是字符串
javascript – Ajax调用在CodeIgniter中返回int而不是字符串
class Itemsale_db extends CI_Model public function getItems($userid,$loc) { $sql = "SELECT disTINCT Name from itransfile where"; if (is_numeric($loc)) $sql .= " location_id = ".$loc; else $sql .= " location_id IN(SELECT location_id FROM client_locations where client_id = " .$userid. ")"; $query = $this->db->query($sql); $item = $query->result_array(); return $item; } }
这是我的控制器. getItemsAjax将调用模型并返回json编码的数组进行查看.
class ItemSale extends CI_Controller { public function getItemsAjax($userid,$Locid) { $this->load->model('itemsale_db'); header('Content-Type: application/x-json; charset=utf-8'); $item = $this->itemsale_db->getItems($userid,$Locid); echo json_encode($item); } }
这是Javascript. loc是位置选择框,items是项目选择框
$(document).ready(function(){ $('#loc').change(function(){ $("#items > option").remove(); var opt = $('<option />'); opt.val('All'); opt.text('All'); $('#items').append(opt); var loc_id = $('#loc').val(); var userid = "<?PHP echo $this->session->userdata('userid'); ?>"; $.ajax({ type: "POST",url: "<?PHP echo base_url()?>" + "index.PHP/itemsale/getItemsAjax/"+loc_id + "/"+userid,success: function(item) { $.each(item,function(Name) { var opt = $('<option />'); opt.val(Name); opt.text(Name); $('#items').append(opt); }); } }); }); });
Ajax调用返回我的整数列表而不是项目名称.
执行console.log(项目)
解决方法
First argument should be index and second should be value in $.each
callback.
这是$.each回调函数的正确格式(Integer indexInArray,Object value)
在ajax成功中使用以下代码:
$.each(item,function(index,Name) {//added index first and then value var opt = $('<option />'); opt.val(Name); opt.text(Name); $('#items').append(opt); });
注意:当您在每个回调中仅使用单个参数时,它会处理名称广告索引.
今天关于javascript – jQuery $().css(“content”)在IE9中返回字符串“normal”和jquery返回值的分享就到这里,希望大家有所收获,若想了解更多关于asp.net – 在Internet Explorer 8中使用ScriptManager.RegisterClientScriptBlock和jQuery时出现问题、c# – jQuery:在jquery ajax json调用中返回字符串响应、javascript - post上传完 返回format: request Content-Type isn''t multipart/form-data、javascript – Ajax调用在CodeIgniter中返回int而不是字符串等相关知识,可以在本站进行查询。
本文标签: