Search Results

Search found 70 results on 3 pages for 'beforesend'.

Page 2/3 | < Previous Page | 1 2 3  | Next Page >

  • JQuery,ajax problem?

    - by user303832
    Hello,I have one table,and when I click on row,it load some content in another table,problem is,when I first time click on row it loads just one time(message 'Some msg' and message 'Some other msg' is showen one time),when I click on other row,it loads twice(messages is shown twice),third time when I click on row it loads three times,ets.Here is my code. $.ajax({ url:'<?php echo $full_path_ajax_php; ?>', data:{'what':'2','mypath':'12345678'}, dataType:'json', type: 'GET', beforeSend:function(){alert('Some msg')}, success: function(){alert('Some other msg')} }); return false; Can someone help me please to understand this.Tnx in advance.

    Read the article

  • JSON.Stringify data including boolean values

    - by ancdev
    What I'm trying to do is to pass JSON object to a WebAPI ajax call and mapped to a strongly typed object on the server side. String values are being posted perfectly however when it comes to boolean values, they are not being passed at all. Below is my code: var gsGasolineField = $('.gsGasoline').val(); blData = { Gasoline: gsGasolineField }; var json = JSON.stringify(blData); $.ajax({ type: "POST", url: url, data: json, contentType: "application/json", dataType: "json", statusCode: { 201 /*Created"*/: function (data) { $("#BusinessLayerDialog").dialog("close"); ClearForm("#BusinessLayerForm"); }, 400: /*Bad request - validation error*/ function (data) { $("#BusinessLayerForm").validate().form(); }, 500: function (data) { alert('err'); } }, beforeSend: setHeader }); Gasoline property is of type boolean on the server side.

    Read the article

  • IE8 + Jquery ajax call giving parsererror from dJango : for json data which seems valid in Firefox

    - by PlanetUnknown
    The ajax call works fine in FF. the data returned is in JSON here is an example from FF firebug - {"noProfiles": "No profiles have been created, lets start now !"} When I try to print the error in IE8 (& in compatibility modes as well), it says "parsererror". But the output seems to be valid JSON. Here is the ajax function call I'm making. Any pointers would be great ! $.ajax({ type: "GET", url: "/get_all_profile_details/", data: "", dataType: "json", beforeSend: function() {alert("before send called");}, success: function(jsonData) { alert("data received"); }, error: function(xhr, txt, err){ alert("xhr: " + xhr + "\n textStatus: " + txt + "\n errorThrown: " + err); } }); The alerts in the error function above give - xhr:<blank> textstatus:parsererror errorThrown: undefined Any pointers would be great ! Note : jquery : 1.3.2

    Read the article

  • Jquery ajax call with '+' sign.

    - by 0plus1
    Hi, I'm doing this: $.ajax({ type: "POST", url: baseURL+"sys/formTipi_azioni",data:"az_tipo="+azione, beforeSend: function(){$("#form").html('<p><img src="'+baseURL+'lib/img/ajax-loader.gif" width="16" height="16" alt="loading" /><p>');}, success: function(html){$("#form").html(html);} }); there is a case when azione is TB+ the plus sign doesn't get POSTed at all, a blank space get sent. I already tried this: azione = escape(String(azione)); With no luck. Does anybody knows how to fix this? Thank you

    Read the article

  • jQuery create new div with ID?

    - by John
    Hello, I have form in my ASP.NET masterPage.master and if i click on submit it call some method from masterPage.master.cs file by ajax (i have it in update panel). But i want improve it with jQuery. So i have this: $('#submit').click(function () { $.ajax({ type: "POST", url: '<% Response.Write("~"+Request.Path); %>', beforeSend: function () { $(document.createElement('div')).width($('#formBox').width()) .height($('#formBox').height()) .css({ backgroundImage: 'url(/Static/Img/bc_overlay.png)', position: 'absolute', left: 0, top: 0, margin: "5px", textAlign: "center", color: "#000", display: "none" }) .append("<strong>Nacítám</strong><br /><img src='Static/Img/ajax-loader.gif' width='33px' height='33px' alt='loading' />") .fadeIn("slow") .prependTo($('#formBox')); $('#formBox').css('position', 'relative'); }, success: function () { } }); }); So if i click on submit, new div is creating (there is loading text and image, and cool opacity overlay), but how i give to this div some ID? Because i need use it in success: function () { } i need clear this box and write here some text (error or success).

    Read the article

  • jquery updating a div in ajax diesnt work properly, when using a variable

    - by maschek
    hi, i got the following code var zieldiv = $(this).attr(\'id\'); $.ajax({ url: \'index.php?params\', type: \'POST\', data: { color:thenewcolor, zieldiv:zieldiv }, timeout: 50000, beforeSend: function() { $("#" + zieldiv).css({background: "#" + thenewcolor} ); } }); I use this for dragging a small div into a bigger div. the variable at the beginnning would give out the string "test1". So in the ajax.thing the css of a div which matches the var zieldiv should be updatet. Problem is, if i would place a string instead a var into the $(...) like $("#test1") it acts like its supposed to, the #test1 gets updated. but if i use the var $("#" + zieldiv) the parent div, which is surrounding the #test1-div gets updated. but i know for sure the var zieldiv contains the string "test1", because when passing it to php it contains "test1". so i think this is a little strange. do you have any ideas? thanx, maschek

    Read the article

  • using ajax url to call function

    - by Steven Vanerp
    Hopefully I can ask this correctly cuz I know what I want it to do but can't seem to find any answers from searching. I have a func.php page where I have all my functions and I want ajax to use one function from that page. func.php function toptable() { echo"something happens in here"; } index.php <?php include 'func.php'; ?> <script type="text/javascript"> function check_username() { uname=document.getElementById("username").value; var params = "user_id="+uname; var url = "topoftable()"; $.ajax({ type: 'POST', url: url, dataType: 'html', data: params, beforeSend: function() { document.getElementById("right").innerHTML= 'checking' ; }, complete: function() { }, success: function(html) { document.getElementById("right").innerHTML= html ; } }); } </script> Make sense?

    Read the article

  • value not posting to php script

    - by user3710364
    step1 batch in dynamically loaded after selecting one of the value from dropdown step 2 is loaded by ajax call in setp 2 when i click on edit step 3 is loaded via ajax call again in step 3 when i click on edit ajax call is working fine but its nit posting the value to php script //ajax call function validateFees(strAddNo) { var collectFees = $("#collectFees").val(); if(collectFees == "") { $("#validateFeesResult").html('<div class="info">Please enter your Fees Amount.</div>'); $("#collectFees").focus(); } else { var dataString = 'collectFees' + collectFees + 'strAddNo' + strAddNo; $.ajax({ type: "POST", url: "validateFees_script.php", data: dataString, cache: false, beforeSend: function() { $("#validateFeesResult").html('Loading...'); }, success: function(response) { $("#validateFeesResult").hide().fadeIn('slow').html(response); } }); } } I'm sure it's extremely simple but I'm not understanding how to do it?

    Read the article

  • Using jQuery, CKEditor, AJAX in ASP.NET MVC 2

    - by Ray Linder
    After banging my head for days on a “A potentially dangerous Request.Form value was detected" issue when post (ajax-ing) a form in ASP.NET MVC 2 on .NET 4.0 framework using jQuery and CKEditor, I found that when you use the following: Code Snippet $.ajax({     url: '/TheArea/Root/Add',     type: 'POST',     data: $("#form0Add").serialize(),     dataType: 'json',     //contentType: 'application/json; charset=utf-8',     beforeSend: function ()     {         pageNotify("NotifyMsgContentDiv", "MsgDefaultDiv", '<img src="/Content/images/content/icons/busy.gif" /> Adding post, please wait...', 300, "", true);         $("#btnAddSubmit").val("Please wait...").addClass("button-disabled").attr("disabled", "disabled");     },     success: function (data)     {         $("#btnAddSubmit").val("Add New Post").removeClass("button-disabled").removeAttr('disabled');         redirectToUrl("/Exhibitions");     },     error: function ()     {         pageNotify("NotifyMsgContentDiv", "MsgErrorDiv", '<img src="/Content/images/content/icons/cross.png" /> Could not add post. Please try again or contact your web administrator.', 6000, "normal");         $("#btnAddSubmit").val("Add New Post").removeClass("button-disabled").removeAttr('disabled');     } }); Notice the following: Code Snippet data: $("#form0Add").serialize(), You may run into the “A potentially dangerous Request.Form value was detected" issue with this. One of the requirements was NOT to disable ValidateRequest (ValidateRequest=”false”). For this project (and any other project) I felt it wasn’t necessary to disable ValidateRequest. Note: I’ve search for alternatives for the posting issue and everyone and their mothers continually suggested to disable ValidateRequest. That bothers me – a LOT. So, disabling ValidateRequest is totally out of the question (and always will be).  So I thought to modify how the “data: “ gets serialized. the ajax data fix was simple, add a .html(). YES!!! IT WORKS!!! No more “potentially dangerous” issue, ajax form posts (and does it beautifully)! So if you’re using jQuery to $.ajax() a form with CKEditor, remember to do: Code Snippet data: $("#form0Add").serialize().html(), or bad things will happen. Also, don’t forget to set Code Snippet config.htmlEncodeOutput = true; for the CKEditor config.js file (or equivalent). Example: Code Snippet CKEDITOR.editorConfig = function( config ) {     // Define changes to default configuration here. For example:     // config.language = 'fr';     config.uiColor = '#ccddff';     config.width = 640;     config.ignoreEmptyParagraph = true;     config.resize_enabled = false;     config.skin = 'kama';     config.enterMode = CKEDITOR.ENTER_BR;       config.toolbar = 'MyToolbar';     config.toolbar_MyToolbar =     [         ['Bold', 'Italic', 'Underline'],         ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', 'Font', 'FontSize', 'TextColor', 'BGColor'],         ['BulletedList', 'NumberedList', '-', 'Outdent', 'Indent'],         '/',         ['Scayt', '-', 'Cut', 'Copy', 'Paste', 'Find'],         ['Undo', 'Redo'],         ['Link', 'Unlink', 'Anchor', 'Image', 'Flash', 'HorizontalRule'],         ['Table'],         ['Preview', 'Source']     ];     config.htmlEncodeOutput = true; }; Happy coding!!! Tags: jQuery ASP.NET MVC 2 ASP.NET 4.0 AJAX

    Read the article

  • JQuery getJSON - ajax parseerror

    - by JW
    I've tried to parse the following json response with both the JQuery getJSON and ajax: [{"iId":"1","heading":"Management Services","body":"<h1>Program Overview</h1><h1>January 29, 2009</h1>"}] I've also tried it escaping the "/" characters like this: [{"iId":"1","heading":"Management Services","body":"<h1>Program Overview <\/h1><h1>January 29, 2009<\/h1>"}] When I use the getJSON it dose not execute the callback. So, I tried it with JQuery ajax as follows: $.ajax({ url: jURL, contentType: "application/json; charset=utf-8", dataType: "json", beforeSend: function(x) { if(x && x.overrideMimeType) { x.overrideMimeType("application/j-son;charset=UTF-8"); } }, success: function(data){ wId = data.iId; $("#txtHeading").val(data.heading); $("#txtBody").val(data.body); $("#add").slideUp("slow"); $("#edit").slideDown("slow"); },//success error: function (XMLHttpRequest, textStatus, errorThrown) { alert("XMLHttpRequest="+XMLHttpRequest.responseText+"\ntextStatus="+textStatus+"\nerrorThrown="+errorThrown); } }); The ajax hits the error ans alerts the following: XMLHttpRequest=[{"iId":"1","heading":"Management Services","body":"<h1>Program Overview </h1><h1>January 29, 2009</h1>"}] textStatus=parseerror errorThrown=undefined Then I tried a simple JQuery get call to return the JSON using the following code: $.get(jURL,function(data){ var json = eval("("+data+");"); wId = json.iId; $("#txtHeading").val(json.heading); $("#txtBody").val(json.body); $("#add").slideUp("slow"); $("#edit").slideDown("slow"); }) The .get returns the JSON, but the eval comes up with errors no matter how I've modified the JSON (content-type header, other variations of the format, etc.) What I've come up with is that there seem to be an issue returning the HTML in the JSON and getting it parsed. However, I have hope that I may have missed something that would allow me to get this data via JSON. Does anyone have any ideas?

    Read the article

  • jQuery.ajax call to Twitter succeeds but returns null for Firefox

    - by Zhami
    I've got code that makes a simple get request to Twitter (search) using jQuery's ajax method. The code works fine on Safari, but fails on Firefox (3.6.3). In the Firefox case, my jQuery.ajax parameters 'success' method is invoked, but the supplied data is null. (In Safari, I receive a boatload of JSON data). My ajax call is: $.ajax({ url: 'http://search.twitter.com/search.json?q='+searchTerm, dataType: 'json', async: true, beforeSend: function(request) { window.console.log('starting AJAX request to get Twitter data'); }, success: function(data, textStatus, request) { window.console.log('AJAX request to get Twitter succeeded: status=' + textStatus); callback(data); }, error: function(request, status, error) { window.console.log('AJAX request to get user data --> Error: ' + status); errback(request, status, error); } }); Firebug shows Response headers: Date Sun, 11 Apr 2010 22:30:26 GMT Server hi Status 200 OK X-Served-From b021 X-Runtime 0.23841 Content-Type application/json; charset=utf-8 X-Served-By sjc1o024.prod.twitter.com X-Timeline-Cache-Hit Miss Cache-Control max-age=15, must-revalidate, max-age=300 Expires Sun, 11 Apr 2010 22:35:26 GMT Vary Accept-Encoding X-Varnish 1827846877 Age 0 Via 1.1 varnish X-Cache-Svr sjc1o024.prod.twitter.com X-Cache MISS Content-Encoding gzip Content-Length 2126 Connection close The HTTP status is OK (200), the Conetnt-Type is properly application/json, and the Content-Length of 2126 (gzip'd) implies data came back. Yet Firebug shows the Response to be empty, and a test of the supplied data shows it o be 'null.' I am aware of a similar post on Stack Overflow: http://stackoverflow.com/questions/1188976/jquery-get-function-succeeds-with-200-but-returns-no-content-in-firefox and from that would assume this problem is possibly related to cross-domain security, but... I know there are many JS widgets and whatnots that ajax get data from Twitter. Is there something I need to enable to allow this?

    Read the article

  • jQuery AJAX slow in Firefox, fast in IE

    - by Brandon Montgomery
    I'm using jQuery to post to an ASP .NET Web Service to implement a custom auto-complete function. The code works great, except it's slow in FireFox (can't get it to go faster than 1 second). IE is blazing fast - works great. I watch the post in Firefox using Firebug. Here's the service code: <ScriptService(), _ WebService(Namespace:="http://tempuri.org/"), _ WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1), _ ToolboxItem(False)> _ Public Class TestWebSvc Inherits System.Web.Services.WebService <WebMethod(), _ ScriptMethod(ResponseFormat:=Script.Services.ResponseFormat.Json, UseHttpGet:=True)> _ Public Function GetAccounts(ByVal q As String) As Object 'Code taken out for simplicity Return result End Function End Class And the jQuery ajax call: $.ajax({ beforeSend: function (req) { req.setRequestHeader("Content-Type", "application/json"); }, contentType: "application/json; charset=utf-8", type: "GET", url: "http://localhost/Suggest/TestWebSvc.asmx/GetAccounts", data: "q='" + element.val() + "'", dataType: "json", success: testWebSvcSuccess }); As you can see, I've tried to use the HTTP GET verb instead in hopes that that would make the call faster. As it does not, I'll probably switch it back to using POST if I can. Right now I'm just focused on why it's super fast in IE and super slow in Firefox. Versions: jQuery 1.3.2; Firefox 3.0.11; IE 8.0.6001.18783 (64-bit) Thank you for any insight you can provide.

    Read the article

  • Jquery Json dynamic variable name generation

    - by PlanetUnknown
    I make a jquery .ajax call and I'm expecting a json result. The catch is, if there are say 5 authors, I'll get author_details_0, author_details_1, author_details_2, etc.... How can I dynamically construct the name of the variable to retrieve from json ? I don't know how many authors I'll get, there could be hundreds. $.ajax({ type: "POST", url: "/authordetails/show_my_details/", data: af_pTempString, dataType: "json", beforeSend: function() { }, success: function(jsonData) { console.log("Incoming from backend : " + jsonData.toSource()); if(jsonData.AuthorCount) { console.log("Number of Authors : " + jsonData.AuthorCount); for (i = 0; i < jsonData.AuthorCount; i++) { temp = 'author_details_' + i; <-------------------This is the name of the variable I'm expecting. console.log("Farm information : " + eval(jsonData.temp) ); <----- This doesn't work, how can I get jsonData.author_details_2 for example, 'coz I don't know how many authors are there, there could be hundreds. } } Please let me know if you have any idea how to solve this ! Much appreciated.

    Read the article

  • Selecting values from a multiselect not working in webkit

    - by azz0r
    Hello! The code below works fine in Firefox. However in Chrome and Safari it doesn't. Essentially it returns an array of values, then selects them from multiselect. However in Chrome and safari it doesn't select the items from the multiselect. $('form#movie select#movie_movie').click(function(){ var id = $(this).val(); $("#movie_category option:selected").attr('selected', ''); $("#movie_model option:selected").attr('selected', ''); $("#movie_gallery option:selected").attr('selected', ''); $("#movie_playlist option:selected").attr('selected', ''); if (id != 0) { $.ajax({ type: 'POST', url: "/administration/link/movie/id/"+id, dataType: 'json', beforeSend: function(x) { $.blockUI({theme: true, title: 'Loading', message: '<p>Please wait...</p>', timeout: 1000}); if(x && x.overrideMimeType) { x.overrideMimeType("application/json;charset=UTF-8"); } }, error: function() { $.unblockUI(); alert('Error loading object, please try again'); }, success: function(returned_values) { $.unblockUI(); $.each(returned_values.object.playlist || {}, function(i, item) {$("#movie_playlist option[value='"+item+"']").attr('selected', 'selected');}); $.each(returned_values.object.category || {}, function(i, item) {$("#movie_category option[value='"+item+"']").attr('selected', 'selected');}); $.each(returned_values.object.model || {}, function(i, item) {$("#movie_model option[value='"+item+"']").attr('selected', 'selected');}); $.each(returned_values.object.gallery || {}, function(i, item) {$("#movie_gallery option[value='"+item+"']").attr('selected', 'selected');}); } }); } }); So the part that isn't working in them is: $("#movie_playlist option[value='"+item+"']").attr('selected', 'selected'); Any ideas??

    Read the article

  • jquery ajax call returning error when its not an error

    - by azz0r
    Hello, My JS Is: $(InitFavorite); function InitFavorite(){ var jList = $(".favourite_link"); var ids_to_check = {};//new Array(); $.each(jList, function () { var id = this.id; var object = id.split("_"); if (!ids_to_check[object[1]]) { ids_to_check[object[1]] = []; } ids_to_check[object[1]].push(object[0]); }); //console.log(ids_to_check); $.ajax({ type: 'POST', url: '/user/subscription/favourite-listing', data: ids_to_check, dataType: 'json', beforeSend: function(x) { if(x && x.overrideMimeType) { x.overrideMimeType("application/j-son;charset=UTF-8"); } }, error: function() { alert(1); }, success: function() { alert(2); /*$each(returned_values, function() { alert('boom'); });*/ } }); } From the ajax call, the following data is returned: {"env":"development","loggedIn":true,"translate":{}}{"Playlist":{"10":"Stop Recieving Updates For This Playlist"},"Clip":{"26":"Recieve Updates For This Clip","27":"Recieve Updates For This Clip","28":"Recieve Updates For This Clip","29":"Stop Recieving Updates For This Clip","30":"Recieve Updates For This Clip"}} However, success is never triggered, just error, despite there being no header and json being put out as the header (via zend framework). Ideas?

    Read the article

  • jQuery date picker not persistant after AJAX

    - by ILMV
    So I'm using the jQuery date picker, and it works well. I am using AJAX to go and get some content, obviously when this new content is applied the bind is lost, I learnt about this last week and discovered about the .live() method. But how do I apply that to my date picker? Because this isn't an event therefore .live() won't be able to help... right? This is the code I'm using to bind the date picker to my input: $(".datefield").datepicker({showAnim:'fadeIn',dateFormat:'dd/mm/yy',changeMonth:true,changeYear:true}); I do not want to call this metho everytime my AJAX fires, as I want to keep that as generic as possible. Cheers :-) EDIT As @nick requested, below is my wrapper function got the ajax() method: var ajax_count = 0; function getElementContents(options) { if(options.type===null) { options.type="GET"; } if(options.data===null) { options.data={}; } if(options.url===null) { options.url='/'; } if(options.cache===null) { options.cace=false; } if(options.highlight===null || options.highlight===true) { options.highlight=true; } else { options.highlight=false; } $.ajax({ type: options.type, url: options.url, data: options.data, beforeSend: function() { /* if this is the first ajax call, block the screen */ if(++ajax_count==1) { $.blockUI({message:'Loading data, please wait'}); } }, success: function(responseText) { /* we want to perform different methods of assignment depending on the element type */ if($(options.target).is("input")) { $(options.target).val(responseText); } else { $(options.target).html(responseText); } /* fire change, fire highlight effect... only id highlight==true */ if(options.highlight===true) { $(options.target).trigger("change").effect("highlight",{},2000); } }, complete: function () { /* if all ajax requests have completed, unblock screen */ if(--ajax_count===0) { $.unblockUI(); } }, cache: options.cache, dataType: "html" }); } What about this solution, I have a rules.js which include all my initial bindings with the elements, if I were to put these in a function, then call that function on the success callback of the ajax method, that way I wouldn't be repeating code... Hmmm, thoughts please :D

    Read the article

  • How to add custom header to ASMX web service call using jquery?

    - by Mike
    I have a web service with the following contract: POST /Service/service.asmx HTTP/1.1 Host: xxx.xxx.xxx Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "xxx.xxx.xxx/Service/Method" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <Request xmlns="xxx.xxx.xxx/Service/"> <transactiontype>string</transactiontype> <username>string</username> <password>string</password> </Request> </soap:Header> <soap:Body> <Method xmlns="xxx.xxx.xxx/Service/"> <xml>xml</xml> </Method> </soap:Body> </soap:Envelope> And I am trying to call the service using jquery. This is my code: $.ajax({ url: serverUrl + 'Method', type: "POST", dataType: "xml", data: { xml: "xml" }, beforeSend: function (req) { req.setRequestHeader('Header', '<Request xmlns="xxx.xxx.xxx/Service/">' +'<transactiontype>4</transactiontype>' +'<agencyName>name</agencyName>' +'<username>user</username>' +'<password>pass</password>' +'</Request>'); }, success: function (data) { alert(data.text); }, error: function (request, status, errorThrown) { alert(status); } }); However, the header content is not passed to the web service? How would I go about passing the header credentials to my web service call?

    Read the article

  • jQuery AJAX Loading Page Content Only After I Press Shift Key

    - by Cosmin
    My ajax + jquery loading page only after holding shift key and duplicate new empty window. If I press the loading button nothing hapen, only after I press shift key I get to load the page correctly... this is my ajax script: $(document).ready(function () { $(".getUsersA").click(function () { $.ajax({ beforeSend: function () { $(".gridD").html(spinner) }, url: 'lib/some_url.php', type: 'POST', data: ({ data1:'2013-09-01' }), success: function (results) {$(".gridD").html(results);} }); }); }); I have a second js file with just this line of code for spinner var spinner = "<img src='images/spinner.gif' border='0'>"; html code: <html> <head> <title>Title</title> <script type="text/javascript" src="js/jquery-1.10.2.js"></script> <script type="text/javascript" src="js/ajax.js"></script> <script type="text/javascript" src="js/general.js"></script> </head> <body> <h1>Putting it all tugether ... with jQuery</h1> <div class="thedivD"><a href="" class="buttonA getUsersA">Get Users</a></div> <h3>jQuery results</h3> <div class="gridD"></div> </body> </html>

    Read the article

  • Multiple forms using Rails & jQuery & AJAX

    - by biggie8199
    I have multiple coupons on a page and I'm trying to get comments to work on each coupon. So for each coupon i have a comments form. Im using jQuery + Ajax to accomplish this. Here's what my code looks like. Coupon Page <p>Comments:</p> <% form_for(@comment) do |f| %> <%= f.label :body %><br /><%= f.text_field :body, :size => "24" %> <%= f.hidden_field :coupon_id, :value => coupon.id %> <%= f.submit "Save" %> <% end %> Application.js jQuery.ajaxSetup({ 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} }) jQuery.fn.submitWithAjax = function() { this.submit(function() { $.post(this.action, $(this).serialize(), null, "script"); return false; }) return this; }; $(document).ready(function() { $("#new_comment").submitWithAjax(); }) I tried changing the jQuery selector to a class $(".new_comment").submitWithAjax(); Thinking that would work, now all the submit buttons work, however it posts only the first form on the page. What can I change to make it so ajax submits the correct form and not the first one?

    Read the article

  • Jquery Ajax Search on pressing return key in Internet Explorer

    - by haribo83
    Hi I have found the following code to create a search on my site - this works really well the only problem is in Internet Explorer the search doesn't work when you press the return key. Does anybody have any ideas? The search code is below - if anything else is needed please let me know. $(function() { $(".search_button").click(function() { var search_word = $("#search_box").val(); var dataString = 'search_word='+ search_word; if(search_word=='') { } else { $.ajax({ type: "GET", url: "searchdata.php", data: dataString, cache: false, beforeSend: function(html) { document.getElementById("insert_search").innerHTML = ''; $("#flash").show(); $("#searchword").show(); $(".searchword").html(search_word); $("#flash").html('<img src="ajax-loader.gif" /> Loading Results...'); }, success: function(html){ $("#insert_search").show(); $("#insert_search").append(html); $("#flash").hide(); } }); } return false; }); });

    Read the article

  • jquery window.unload triggers post after unload

    - by index
    I am trying to do a post to server before unloading a page and I followed this and it's working fine. My problem is the $.post on window.unload is triggered after it has unloaded. I tried it with a signout link and checking on my logs, I get the following: Started GET "/signout" for 127.0.0.1 at 2012-11-22 00:15:08 +0800 Processing by SessionsController#destroy as HTML Redirected to http://localhost:3000/ Completed 302 Found in 1ms Started GET "/" for 127.0.0.1 at 2012-11-22 00:15:08 +0800 Processing by HomeController#index as HTML Rendered home/index.html.erb within layouts/application (0.4ms) Rendered layouts/_messages.html.erb (0.1ms) Completed 200 OK in 13ms (Views: 12.9ms) Started POST "/unloading" for 127.0.0.1 at 2012-11-22 00:15:08 +0800 Processing by HomeController#unloading as */* Parameters: {"p1"=>"1"} WARNING: Can't verify CSRF token authenticity Completed 500 Internal Server Error in 0ms NoMethodError (undefined method `id' for nil:NilClass): app/controllers/home_controller.rb:43:in `unloading' First part is the signout and then user gets redirected to root then it runs the post ('/unloading'). Is there a way to make the '/unloading' execute first then execute whatever the unload action was? I have this as my jquery post $(window).unload -> $.ajax { async: false, beforeSend: (xhr) -> xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content')) , url: '/unloading' , type: 'Post' , data: { p1: '1' } }

    Read the article

  • JSON datas not loaded into content page

    - by Chelseawillrecover
    I am trying to append my JSON datas into the content page but the datas are not loaded. When I use console.log I can see the data appearing. JS: $(document).on('pagebeforeshow', '#blogposts', function() { //$.mobile.showPageLoadingMsg(); $.ajax({ url: "http://howtodeployit.com/category/daily-devotion/?json=recentstories&callback=", dataType: "json", jsonpCallback: 'successCallback', async: true, beforeSend: function() { $.mobile.showPageLoadingMsg(true); }, complete: function() { $.mobile.hidePageLoadingMsg(); }, success:function(data){ $.each(data.posts, function(i, val) { console.log(val.title); $('<li/>').append([$("<h3>", {html: val.title}),$("<p>", {html: val.excerpt})]).wrapInner('<a href="#devotionpost" onclick="showPost(' + val.id + ')"></a>').appendTo('#postList'); return (i !== 4); console.log('#postlist'); }); }, error: function(data) { alert("Data not found"); } }); }); HTML: <!-- Page: Blog Posts --> <div id="blogposts" data-role="page"> <div data-role="header" data-position="fixed"> <h2>My Blog Posts</h2> </div><!-- header --> <div data-role="content"> <ul id="postlist"> </ul><!-- content --> </div> <div class="load-more">Load More Posts...</div> </div><!-- page -->

    Read the article

  • Redirect To Another Site With Header Information Attached Javascript

    - by Nick LaMarca
    I am trying to make a client side click and redirect to another site with header information added, my client side code for the onclick is this: function selectApp(appGUID, userId ,embedUrl) { if(embedUrl==="") { var success = setAppGUID(appGUID); window.location.replace('AppDetail.aspx'); } else { $.ajax({ type: "POST", url: embedUrl, contentType: "text/html", beforeSend: function (xhr, settings) { xhr.setRequestHeader("UserId", userId); }, success: function (msg) { //go to slx window.location.replace(embedUrl); } }); } } And the server side code in "embedUrl" is protected void Page_Load(object sender, EventArgs e) { string isSet = (String)HttpContext.Current.Session["saveUserID"]; if (String.IsNullOrEmpty(isSet)) { NameValueCollection headers = base.Request.Headers; for (int i = 0; i < headers.Count; i++) { if (headers.GetKey(i).Equals("UserId")) { HttpContext.Current.Session["saveUserID"] = headers.Get(i); } } } else { TextBox1.Text = HttpContext.Current.Session["saveUserID"].ToString(); } } This seems to work but its not too elegant. Is there a way to redirect with header data? Without (what Im doing) Saving header info in a session var then doing a redirect in 2 seperate pieces.

    Read the article

  • how to call a js function from loaded jquery

    - by Y.G.J
    the function is in the page loading the ajax but i'm trying to call the function codes: [ajax] $.ajax({ type: "POST", url: "loginpersonal.asp", data: "id=<%=request("id")%>", beforeSend: function() { $("#personaltab").hide(); }, success: function(msg){ $("#personaltab").empty().append(msg); }, complete: function() { $("#personaltab").slideDown(); }, error: function() { $("#personaltab").append("error").slideDown(); } }); [the js function] function GetCount(t){ if(t>0) { total = t } else { total -=1; } amount=total; if(amount < 0){ startpersonalbid(); } else{ days=0;hours=0;mins=0;secs=0;out=""; days=Math.floor(amount/86400);//days amount=amount%86400; hours=Math.floor(amount/3600);//hours amount=amount%3600; mins=Math.floor(amount/60);//minutes amount=amount%60; secs=Math.floor(amount);//seconds if(days != 0){out += days +":";} if(days != 0 || hours != 0){out += hours +":";} if(days != 0 || hours != 0 || mins != 0){out += ((mins>=10)?mins:"0"+mins) +":";} out += ((secs>=10)?secs:"0"+secs) ; document.getElementById('countbox').innerHTML=out; setTimeout("GetCount()", 1000); } } window.onload=function(){ GetCount(<%= DateDiff("s", Now,privatesellstartdate&" "&privatesellstarttime ) %>); so at the end of the loginpersonal.asp from the ajax... if it does what it suppose to do... i'm trying to call the function GetCount() again.

    Read the article

  • Rails 2.3.4 and jquery form plugin works on development, not in production?

    - by hemajang
    Hello, i'm trying to build a contact form in Rails 2.3.4. I'm using the jQuery Form plugin along with this (http://bassistance.de/jquery-plugins/jquery-plugin-validation/) for validations. Everything works in my development environment (mac os x snow leopard), the loading gif appears and on my log the email gets sent and the "request completed" notice shows. But on my production machine the loading gif just keeps going and the form doesn't get sent. I've waited as long as I could, nothing. Here is my code: /public/javascripts/application.js // client-side validation and ajax submit contact form $('#contactForm').validate( { rules: { 'email[name]': { required: true }, 'email[address]': { required: true, email: true }, 'email[subject]': { required: true }, 'email[body]': { required: true } }, messages: { 'email[name]': "Please enter your name.", 'email[address]': "Please enter a valid email address.", 'email[subject]': "Please enter a subject.", 'email[body]': "Please enter a message." }, submitHandler: function(form) { $(form).ajaxSubmit({ dataType: 'script', beforeSend: function() { $(".loadMsg").show(); } }); return false; } }); I'm using the submitHandler to send the actual ajaxSubmit. I added the "dataType: "script" and the "beforeSubmit" for the loading graphic. def send_mail if request.post? respond_to do |wants| ContactMailer.deliver_contact_request(params[:email]) flash[:notice] = "Email was successfully sent." wants.js end end end Everything works fine on development, but not in production. What am I missing or did wrong?

    Read the article

< Previous Page | 1 2 3  | Next Page >