JqGrid : File Upload not working - jquery-ui

I am trying to upload file with jqgrid, but the is some mistake in my code.
I am using onInitializeForm method.
I am using Jquery Ajax File Uploader
Can anyone do help to me?
You can see Error in screenshot
This is my code.
jQuery("#formGrid").jqGrid(
{
url:'application/ajax/common_form_detail.php?form_id='+form_id,
editurl:'application/ajax/common_form_edit.php?form_id='+form_id,
datatype: "json",
colNames:[<?php echo $strfield; ?>],
colModel:[<?php echo $strFieldModel; ?>],
rowNum:20,
rowList:[20,50,100],
pager: '#formControl',
sortname: 'id',
viewrecords: true,
sortorder: "asc",
autowidth: true,
height: 400,
width: 900
});
jQuery("#formGrid").jqGrid('navGrid','#formControl',
{ edit:true,add:true,del:true,search:false},
{width:780,recreateForm:true},
{width:780,recreateForm:true
,onInitializeForm : function(formid){
$(formid).attr('method','POST');
$(formid).attr('action','');
$(formid).attr('enctype','multipart/form-data');
}, afterSubmit : function(response, postdata){
$.ajaxFileUpload({
url: 'application/ajax/common_file_upload.php',
secureuri:false,
fileElementId:'STUDENT_AVATAR',
dataType: 'json',
success: function (data, status) {
alert("Upload Complete.");
}
});
}
});
});

One can see that you have error in jQuery.handleError function which is depreciated from jQuery 1.5. jQuery Ajax File Uploader V2.1 provided from the download page included jQuery 1.2.1.
One have to fix the code of Ajax File Uploader to solve the problem. See the answer and the answer for example or this one. You can consider to use another Plugin for file upload like jQuery Form Plugin (and here), see here.

Related

HighCharts Editor Plugin Example not working

So I have the jquery-simple-rest plugin for Highcharts, (same used in the example documentation). I've linked the js file, and am not getting any errors in my browser. The documentation mentions also needing to the highed.use.
//The installer
highed.plugins.editor.install("jquery-simple-rest",{
//Contains information about the plugin - optional
meta:{
version:"1.0.0",
author:"Highsoft",
homepage:"https://github.com/highcharts/highcharts-editor/plugins/jquery-simple-rest.js"
},
//Add additional external dependencies here
dependencies:[
"https://code.jquery.com/jquery-3.1.0.min.js"
],
//This is the prototype options which the plugin accepts
options:{
url:{
required:!0,
type:"string"}
},
//Called when the chart changes
chartchange:function(e,t)
{jQuery.ajax({
url:t.url,
data:e.json,
dataType:"json",
type:"post"
,success:function(){
highed.snackBar("CHART SAVED")
},
error:function(e,t){
highed.snackBar("unable to save chart: "+t)
}
})
}
});
highed.plugins.editor.use('jquery-simple-rest', {options:{
url:{
required:!0,
type:"string"}
},
}
);
I can not get this plugin to appear in my the editor, and have no idea what it is I'm doing wrong.
link to example: https://github.com/highcharts/highcharts-editor/wiki/Plugins

jQuery autocomplete runs every pageLoad

I am using jQuerys autocomplete. When page is load below ajax run automaticly. But i want to do this if anyone keydown this textbox. How can i change ?
$('#txtFirmaAdlari').autocomplete({
source: function (request, response) {
$.ajax({
url: '/Fatura/GetFirma/',
dataType: "json",
cache: false,
traditional: true,

HTML5 FormData file upload with RubyOnRails

I using this script to upload file (one by one) with HTML5 FormData in Rails 3.2.8 application.
http://jsfiddle.net/RamPr/
$('.uploader input:file').on('change', function() {
$this = $(this);
$('.alert').remove();
$.each($this[0].files, function(key, file) {
$('.files').append('<li>' + file.name + '</li>');
data = new FormData();
data.append(file.name, file);
$.ajax({
url: $('.uploader').attr('action'),
contentType: 'multipart/form-data',
type: 'POST',
dataType: 'json',
data: data,
processData: false
});
});
});
But when I upload a file, I get this error in console:
webrick/server.rb:191:in `block in start_thread' ERROR ArgumentError: invalid %-encoding ("filename.jpeg" Content-Type: image/jpeg
How can I solve this error?
Have you seen this issue? Sending multipart/formdata with jQuery.ajax
It looks like you might be running into jQuery adding content-type headers, which causes the boundary string to be missing. From the above linked issue:
It’s imperative that you set the contentType option to false, forcing jQuery not to add a Content-Type header for you, otherwise, the boundary string will be missing from it. Also, you must leave the processData flag set to false, otherwise, jQuery will try to convert your FormData into a string, which will fail.
Based on that, give this a try:
$.ajax({
url: $('.uploader').attr('action'),
contentType: false,
cache: false,
processData: false,
type: 'POST',
dataType: 'json',
data: data
});
I haven't tried this myself, but I suspect this might be the droids you're looking for :)

JQuery UI dialog cannot load page content dynamically?

I have used a tutorial http://www.devcurry.com/2010/06/load-page-dynamically-inside-jquery-ui.html to dynammically load an aspx page into a jquery ui dialog without using an iframe
eg.
$(function() {
$('<div>').dialog({
autoOpen: true,
modal: true,
open: function() {
$(this).load('Example.aspx');
},
height: 400,
width: 400,
title: 'Dynamically Loaded Page'
});
When I debugged this page it just loading a blank dialog box with none of the content in even though the page has content. I have written it with the paths
eg $(this).load('/Home/Example.aspx');
I have even added in a function to check if it is loading
eg $(this).load('/Home/Example.aspx', function(){alert(Load Successful);}); which does return true YET still no content in the dialog
I am using Jquery 1.3.2 an ui 1.7.3 with ASP.Net Mvc
I know there are lots of questions/answers on this topic on stackoverflow but none of them seem to be successfully answering my problem and as these questions seem a year old not sure whether someone will get back to me asap.
Any ideas on showing the content in the dialog
Thank you
Just a thought, try changing your selector to
$('<div></div>').dialog({
Also the example you cited is using jquery 1.4.2 and jquery ui 1.8.1,
can you upgrade?
Edit:
You could also try it this way.
$(function() {
$('<div></div>').load('Example.aspx', {},
function(data) {})
.dialog(
{
autoOpen: true,
modal: true,
height: 400,
width: 400,
title: 'Dynamically Loaded Page'
}).dialog('open');
});
Note I haven't tested this, but its the way I do it. Hopefully you get the idea.
The answer is...
$(function() {
$('<div></div>').hide().load('Home/Example #content_form', function() {
$(this).dialog({
autoOpen: true,
modal: true,
height: 400,
width: 400,
title: 'Dynamically Loaded Page'
})
})
With Example.aspx having a tag with ID = content_form

How do I get the Id of a button of a jquery UI dialog?

as the title says....
this is what I have tried but not working
$('#uxReferralAssessmentDetailsDialog').dialog({
autoOpen: false,
modal: true,
width: 400,
title: "Referral Assessment",
buttons: { "Save":{ id: 'uxbtnSaveAssessment', click:othis.OnAssessmentSave}, "Cancel": function() { $(this).dialog("close"); } }
});
I am using selenium and instead of the horrid xpath I want to use the id of each element to simplify the xpath
any ideas welcome
If you are having a hard time determining id as and other things that are being added to the html page by javascript on the fly. Try using a development tool for web browsers like firebug which is an addon for firefox:
See link for firebug addon for more information:
https://addons.mozilla.org/en-US/firefox/addon/1843

Resources