Search Results

Search found 378 results on 16 pages for 'responsetext'.

Page 1/16 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Comet, responseText and memory usage

    - by ithcy
    Is there a way to clear out the responseText of an XHR object without destroying the XHR object? I need to keep a persistent connection open to a web server to feed live data to a browser. The problem is, there is a relatively large amount of data coming through (several hundred K per second constantly), so memory usage is a big problem, because this connection must remain open for at least several minutes. responseText gets very big very quickly, even though the JSON I send back has been crunched as small as it can get. Due to the way the server-side app works, if I use AJAX-style short polling and just destroy the XHR object when I'm done with it, I miss significant amounts of important data even in the few milliseconds it takes to parse the response, create a new XHR and send it out. I do not have the option to use overlapping requests, as the web server only accepts one connection at a time. (Don't ask.) So Comet is exactly the model I need. What I would like to do is parse each JSON chunk as it comes back from the server, and then clear out responseText so that I can keep using the same connection. However, responseText is read-only. It cannot be directly emptied by any method I have found. Is there a part of the picture I am missing here? Does anyone know any tricks I can use to free up responseText when I'm done reading it? Or is there another place the server responses can go? I am not including code because this is really almost a code-agnostic question. The Javascript routines that spawn the XHRs and handle the returned data are very, very simple.

    Read the article

  • MooTools: How to use responseText directly

    - by Johny
    In following example of code, I want to traverse the responseText object which consist the html code came from request_page.php file. In onSuccess event, i want to check whether < Div with id 'ersDiv' has any errors posted in it. new Request.HTML({ url: 'request_page.php', onSuccess: function(responseText, responseXML) { // My expected code to handle responseText object alert(errorMessage); }, onFailure: function() { } }); request_page.php file is like this : <div align='center'><div id='ersDiv'>Page loaded with insufficient data</div></div>

    Read the article

  • JQuery AJAX responseText to JSON

    - by BoredOfBinary
    I have this script that calls a .net WebService msg = $.toJSON( $.ajax({ type: "POST", url: "http://[url]/ETS.UI/WebServices/LocationService.asmx/GetMappingLocationDetails", contentType: "application/json; charset=utf-8", data: $.toJSON({'componentId':994}), dataType: "json", async: false }).responseText ); And I recieve the following value in the msg variable: ""{\"d\":\"{\\"ComponentId\\":994,\\"Latitude\\":32.219627009236405,\\"Longitude\\":-110.96843719482422,\\"LocationName\\":\\"Tucson\\",\\"StreetAddress\\":\\"7201 E 22nd Street \\",\\"City\\":\\"Tucson\\",\\"State\\":\\"AZ\\",\\"PostalCode\\":null}\"}"" I have no idea why this would format this way, seems to only do this in responseText. Does anyone have any ideas?

    Read the article

  • Empty responseText from XMLHttpRequest

    - by PurplePilot
    I have written an XMLHttpRequest which runs fine but returns an empty responseText. The javascript is as follows: var anUrl = "http://api.xxx.com/rates/csv/rates.txt"; var myRequest = new XMLHttpRequest(); callAjax(anUrl); function callAjax(url) { myRequest.open("GET", url, true); myRequest.onreadystatechange = responseAjax; myRequest.setRequestHeader("Cache-Control", "no-cache"); myRequest.send(null); } function responseAjax() { if(myRequest.readyState == 4) { if(myRequest.status == 200) { result = myRequest.responseText; alert(result); alert("we made it"); } else { alert( " An error has occurred: " + myRequest.statusText); } } } The code runs fine. I can walk through and I get the readyState == 4 and a status == 200 but the responseText is always blank. I am getting a log error (in Safari debug) of Error dispatching: getProperties which I cannot seem to find reference to. I have run the code in Safari and Firefox both locally and on a remote server. The URL when put into a browser will return the string and give a status code of 200. I wrote similar code to the same URL in a Mac Widget which runs fine, but the same code in a browser never returns a result.

    Read the article

  • Cannot get xmlhttprequest.responseText from JQuery

    - by Felix Guerrero
    Hi. I got this function function verify_at_bd(){ var u = "foo"; var p = "bar"; return $.post('auth.php', { name: u, password: p, mobile: '' }, function(result){ return result; },'json'); } If I do a console.log(verify_at_bd()) I'm getting an xmlhttprequest but cannot access to responseText property. I'm using header("Content-Type: application/json") into my PHP. I'm using firefox 3.6 on OS X.

    Read the article

  • receive a responseText in ajax but without div tag

    - by kawtousse
    Hi everyone I want to know if there is any other way whithout using a div tag to receive response html when sending parameter whith ajax. I'am asking because when iam building the select in other servlet and returning the result to jsp it receive the responsehtml in a div tag when we use the famous: x = xhr.responseText; document.getElementById('param').innerHTML = x; with param is the id of div tag. Note: this works fine when populating ddl but its constraint are multiple for my case. Thinks.

    Read the article

  • Getting the responseText from XMLHttpRequest-Object

    - by Sammy46
    I wrote a cgi-script with c++ to return the query-string back to the requesting ajax object. I also write the query-string in a file in order to see if the cgi script works correctly. But when I ask in the html document for the response Text to be shown in a messagebox i get a blank message. here is my code: js: <script type = "text/javascript"> var XMLHttp; if(navigator.appName == "Microsoft Internet Explorer") { XMLHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else { XMLHttp = new XMLHttpRequest(); } function getresponse () { XMLHttp.open ("GET", "http://localhost/cgi-bin/AJAXTest?" + "fname=" + document.getElementById('fname').value + "&sname=" + document.getElementById('sname').value,true); XMLHttp.send(null); } XMLHttp.onreadystatechange=function(){ if(XMLHttp.readyState == 4) { document.getElementById('response_area').innerHTML += XMLHttp.readyState; var x= XMLHttp.responseText alert(x) } } </script> First Names(s)<input onkeydown = "javascript: getresponse ()" id="fname" name="name"> <br> Surname<input onkeydown = "javascript: getresponse();" id="sname"> <div id = "response_area"> </div> C++: int main() { QFile log("log.txt"); if(!log.open(QIODevice::WriteOnly | QIODevice::Text)) { return 1; } QTextStream outLog(&log); QString QUERY_STRING= getenv("QUERY_STRING"); //if(QUERY_STRING!=NULL) //{ cout<<"Content-type: text/plain\n\n" <<"The Query String is: " << QUERY_STRING.toStdString()<< "\n"; outLog<<"Content-type: text/plain\n\n" <<"The Query String is: " <<QUERY_STRING<<endl; //} return 0; } I'm happy about every advice what to do! EDIT: the output to my logfile works just fine: Content-type: text/plain The Query String is: fname=hello&sname=world I just noticed that if i open it with IE8 i get the query-string. But only on the first "keydown" after that IE does nothing.

    Read the article

  • jquery WebService responseXML / responseText

    - by Kevin
    I get an empty response back from this local WebService call via jquery / ajax. I have verified the URL and XML input string by invoking the call in a browser. I DO get XML code back as expected. What am I missing? Could it have something to do with the return type "XmlDocument"? I have tried changing out text/xml to text. No affect. Tried a GET instead of POST. Webservice (running locally)... _ Public Function GetXML(ByVal strXML As String) As XmlDocument... Dim retXML As XmlDocument = New XmlDocument() ...CODE.... Return retXML Calling Function: # GetStat() { var Url = 'http://localhost/myService.asmx?op=GetXML'; var msg = ' 55 POPE myUser myPwd '; $.ajax({ url: Url, type: "POST", dataType: "text/xml", data: msg, complete: processResult, contentType: "text/xml" }); return false; } function processResult(xmlData, status) { var jData = $(xmlData); } # Thanks!

    Read the article

  • jquery ajax call errors in chrome onenter with no responseText

    - by wham12
    I've built a login page that uses a .ajax call to a generic c# handler (.ashx) to validate the username and password before allowing the user to log in. If you click on the login link <a href="#" class="ui-state-default ui-corner-all CustomButton" onclick="goLogin();return false"> the .ajax call returns successfully and it logs the user in. I am trying to make it so the user can also just press the "enter" key from the password box: $("#pword").keydown(function(e) { if (e.keyCode == 13) { goLogin(); } }); Using Firefox, both ways work just fine and the user is logged in. With Chrome however, pressing "enter" hits the error function of my .ajax call and will not log the user in. The parameters and responses look identical through Firefox's console, as expected. What would be causing this and/or how can I debug it in Chrome?

    Read the article

  • xmlhttprequest responsetext coming for Accept header: text/xml , but server error for application/JS

    - by encryptor
    I have to get response text from a resourceindex page as JSON object. When I dont put a Accept header in the request, it shows me the xml response (i see it in an alert).. But I want the response as a JSON object.. What should I do. One solution would have been httpRequest.setRequestHeader('Accept', 'application/JSON'); but this gives me a server error :500 Also it says A message body writer for Java type, class ...., and MIME media type, application/octet-stream, was not found Can someone suggest on what to do to overcome this and get the response as JSON?

    Read the article

  • Prototype Ajax.Updater Response OK, but not showing up in FF. working in Safari!

    - by koko
    Hi, I've got a quite strange problem here. I'm calling some simple code via Ajax.Updater: new Ajax.Updater('load','http://myurl.com/demo.pl?key=demokey&param1=xyz&param2=abc',{ method:'get', onComplete:function(transport){ alert(transport.responseText) } }); which gets some code like this: <img id="2009_04_15_1239786246" src='../pv/100/2009_04_15_1239786246-01.jpg' border="1"> <img id="2009_04_15_1239786066" src='../pv/100/2009_04_15_1239786066-01.jpg' border="1"> ... and so on This code shows up in my firebug console as my server response, so everything should be fine. No errors here at all. Works fine in Safari. Firefox, according to Firebug, knows there is a response, but it won't show a thing in my div 'load' and the alert(transport.responseText) is also empty. I have no idea what could be the problem here.

    Read the article

  • Assigning jQuery ajax response text to variable constanty returns null

    - by Dan Twining
    Hi all, hopefully one of you on this great site can help. I'm having issues with assigning a variable to a jQuery ajax call response text. I have a form which when submited runs my "checkemail" function to varify the email address can be found in a database. If it's found, the responseText == "true", else "false". This works fine, and can be seen ok using Firebug....but the actual variable the response text should be assigned to is constantly showing "", and therefore causing the function to return false all the time. function checkemail(){ var EmailFromForm = $("#lostemail").val(); var EmailCheckRes = $.ajax({ type : "POST", cache : false, url : "./scripts/passreset/emailcheck.php", data : "Email="+EmailFromForm, dataType : "text", }).responseText; if (EmailCheckRes == "true") { alert("Should say true: " + EmailCheckRes); return true; } else { $("#ErrorMsg").html("Your email address is either invalid or not found."); alert("Should say false: " + EmailCheckRes); return false; } } If anyone has any pointers as to what i'm doing wrong it'd be greatly appreciated.

    Read the article

  • Ajax request with prototype - what is transport if not only responseText?

    - by Delirium tremens
    This is an example code from the prototype site. var url = '/proxy?url=' + encodeURIComponent('http://www.google.com/search?q=Prototype'); // notice the use of a proxy to circumvent the Same Origin Policy. new Ajax.Request(url, { method: 'get', onSuccess: function(transport) { var notice = $('notice'); if (transport.responseText.match(/href="http:\/\/prototypejs.org/)) notice.update('Yeah! You are in the Top 10!').setStyle({ background: '#dfd' }); else notice.update('Damn! You are beyond #10...').setStyle({ background: '#fdd' }); } }); The data that comes from the ajax request is available at transport.responseText, but what is transport if not only responseText?

    Read the article

  • Wasteful Ajax Page Loading

    - by Matt Dawdy
    I've started a new job, and the portion of the project I'm working has a very odd structure. Every pages is a .Net aspx page, and it loads just fine, but nothing is really done at load time. Everything is really loaded from a jquery document.onready handler. What is even more...interesting...is that the onready handler calls some ajax calls that drop entire .aspx pages into divs on the page, but first it strips out several parts of the the returned page. This is the "magic" script the previous programmer ran on all the returned html from his ajax calls: function CleanupResponseText(responseText, uniqueName) { responseText = responseText.replace("theForm.submit();", "SubmitSubForm(theForm, $(theForm).parent());"); responseText = responseText.replace(new RegExp("theForm", "g"), uniqueName); responseText = responseText.replace(new RegExp("doPostBack", "g"), "doPostBack" + uniqueName); return responseText; } He then intercepts any kind of form postback and runs his own form submission function: function SubmitSubForm(form, container) { //ShowLoading(container); $(form).ajaxSubmit( { url: $(form).attr("action"), success: function(responseText) { $(container).html(CleanupResponseText(responseText, form.id)); $("form", container).css("margin-top", "0").css("padding-top", "0"); //HideLoading(container); } } ); } Am I way offbase in thinking that this is less than optimal? I mean, how does a browser take out the html and head and other tags that don't have anything to do with what you are really trying to drop into that div? Also, he's returning things like asp:gridview controls, and the associate viewstate, which can be quite large if his dataset is big. Has anyone seen this before?

    Read the article

  • xmlhttp.responseText and xmlhttp.readyState works fine with localhost but if i use IP address it is

    - by hemant
    Hi All, xmlhttp.responseText and xmlhttp.readyState works fine with localhost but if i use IP address it is not returning values same as localhost. function getFilenames() { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url="GetFileNames.php"; xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function stateChanged() { if (xmlhttp.readyState == 4) { StringFileName = xmlhttp.responseText; } else { StringFileName = null; } } Regards Hemant

    Read the article

  • XmlHttpRequest in a bookmarklet returns empty responseText on GET?

    - by David Eyk
    I'm trying to build a javascript bookmarklet for a special URL shortening service we've built at http://esv.to for shortening scripture references (i.e. "Matthew 5" becomes "http://esv.to/Mt5". The bookmarklet is supposed to do a GET request to http://api.esv.to/Matthew+5, which returns a text/plain response of http://esv.to/Mt5. The code for the bookmarklet itself looks like this (expanded for readability): var body = document.getElementsByTagName('body')[0], script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'http://esv.to/media/js/bookmarklet.js'; body.appendChild(script); void(0); The code from http://esv.to/media/js/bookmarklet.js looks like this: (function() { function shorten(ref, callback) { var url = "http://esv.to/api/" + escape(ref); var req = new XMLHttpRequest(); req.onreadystatechange = function shortenIt() { if ( this.readyState == 4 && this.status == 200 ) { callback(req.responseText); }; }; req.open( "GET", url ); req.send(); }; function doBookmarklet() { var ref = prompt("Enter a scripture reference or keyword search to link to:", "") shorten(ref, function (short) { prompt("Here is your shortened ESV URL:", short); }); }; doBookmarklet(); })(); When called from http://esv.to itself, the bookmarklet works correctly. But when used on another page, it does not. The strange thing is, when I watch the request from Firebug, the response is 200 OK, the browser downloads 17 bytes (the length of the returned string), but the response body is empty! No error is thrown, just an empty responseText on the XmlHttpRequest object. Now, according to http://stackoverflow.com/questions/664689/ajax-call-from-bookmarklet, GET shouldn't violate the same origin policy. Is this a bug? Is there a workaround?

    Read the article

  • ajaxSubmit and Other Code. Can someone help me determine what this code is doing?

    - by Matt Dawdy
    I've inherited some code that I need to debug. It isn't working at present. My task is to get it to work. No other requirements have been given to me. No, this isn't homework, this is a maintenance nightmare job. ASP.Net (framework 3.5), C#, jQury 1.4.2. This project makes heavy use of jQuery and AJAX. There is a drop down on a page that, when an item is chosen, is supposed to add that item (it's a user) to an object in the database. To accomplish this, the previous programmer first, on page load, dynamically loads the entire page through AJAX. To do this, he's got 5 div's, and each one is loaded from a jquery call to a different full page in the website. Somehow, the HTML and BODY and all the other stuff is stripped out and the contents of the div are loaded with the content of the aspx page. Which seems incredibly wrong to me since it relies on the browser to magically strip out html, head, body, form tags and merge with the existing html head body form tags. Also, as the "content" page is returned as a string, the previous programmer has this code running on it before it is appended to the div: function CleanupResponseText(responseText, uniqueName) { responseText = responseText.replace("theForm.submit();", "SubmitSubForm(theForm, $(theForm).parent());"); responseText = responseText.replace(new RegExp("theForm", "g"), uniqueName); responseText = responseText.replace(new RegExp("doPostBack", "g"), "doPostBack" + uniqueName); return responseText; } When the dropdown itself fires it's onchange event, here is the code that gets fired: function SubmitSubForm(form, container) { //ShowLoading(container); $(form).ajaxSubmit( { url: $(form).attr("action"), success: function(responseText) { $(container).html(CleanupResponseText(responseText, form.id)); $("form", container).css("margin-top", "0").css("padding-top", "0"); //HideLoading(container); } } ); } This blows up in IE, with the message that "Microsoft JScript runtime error: Object doesn't support this property or method" -- which, I think, has to be that $(form).ajaxSubmit method doesn't exist. What is this code really trying to do? I am so turned around right now that I think my only option is to scrap everything and start over. But I'd rather not do that unless necessary. Is this code good? Is it working against .Net, and is that why we are having issues?

    Read the article

  • Image Preview in ASP.NET MVC

    - by imran_ku07
      Introduction :         Previewing an image is a great way to improve the UI of your site. Also it is always best to check the file type, size and see a preview before submitting the whole form. There are some ways to do this using simple JavaScript but not work in all browsers (like FF3).In this Article I will show you how do this using ASP.NET MVC application. You also see how this will work in case of nested form.   Description :          Create a new ASP.NET MVC project and then add a file upload and image control into your View. <form id="form1" method="post" action="NerdDinner/ImagePreview/AjaxSubmit">            <table>                <tr>                    <td>                        <input type="file" name="imageLoad1" id="imageLoad1"  onchange="ChangeImage(this,'#imgThumbnail')" />                    </td>                </tr>                <tr>                    <td align="center">                        <img src="images/TempImage.gif" id="imgThumbnail" height="200px" width="200px">                     </td>                </tr>            </table>        </form>           Note that here NerdDinner is refers to the virtual directory name, ImagePreview is the Controller and ImageLoad is the action name which you will see shortly          I will use the most popular jQuery form plug-in, that turns a form into an AJAX form with very little code. Therefore you must get these from Jquery site and then add these files into your page.          <script src="NerdDinner/Scripts/jquery-1.3.2.js" type="text/javascript"></script>        <script src="NerdDinner/Scripts/jquery.form.js" type="text/javascript"></script>            Then add the javascript function. <script type="text/javascript">function ChangeImage(fileId,imageId){ $("#form1").ajaxSubmit({success: function(responseText){ var d=new Date(); $(imageId)[0].src="NerdDinner/ImagePreview/ImageLoad?a="+d.getTime(); } });}</script>             This function simply submit the form named form1 asynchronously to ImagePreviewController's method AjaxSubmit and after successfully receiving the response, it will set the image src property to the action method ImageLoad. Here I am also adding querystring, preventing the browser to serve the cached image.           Now I will create a new Controller named ImagePreviewController. public class ImagePreviewController : Controller { [AcceptVerbs(HttpVerbs.Post)] public ActionResult AjaxSubmit(int? id) { Session["ContentLength"] = Request.Files[0].ContentLength; Session["ContentType"] = Request.Files[0].ContentType; byte[] b = new byte[Request.Files[0].ContentLength]; Request.Files[0].InputStream.Read(b, 0, Request.Files[0].ContentLength); Session["ContentStream"] = b; return Content( Request.Files[0].ContentType+";"+ Request.Files[0].ContentLength ); } public ActionResult ImageLoad(int? id) { byte[] b = (byte[])Session["ContentStream"]; int length = (int)Session["ContentLength"]; string type = (string)Session["ContentType"]; Response.Buffer = true; Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = type; Response.BinaryWrite(b); Response.Flush(); Session["ContentLength"] = null; Session["ContentType"] = null; Session["ContentStream"] = null; Response.End(); return Content(""); } }             The AjaxSubmit action method will save the image in Session and return content type and content length in response. ImageLoad action method will return the contents of image in response.Then clear these Sessions.           Just run your application and see the effect.   Checking Size and Content Type of File:          You may notice that AjaxSubmit action method is returning both content type and content length. You can check both properties before submitting your complete form.     $(myform).ajaxSubmit({success: function(responseText)            {                                var contentType=responseText.substring(0,responseText.indexOf(';'));                var contentLength=responseText.substring(responseText.indexOf(';')+1);                // Here you can do your validation                var d=new Date();                $(imageId)[0].src="http://weblogs.asp.net/MoneypingAPP/ImagePreview/ImageLoad?a="+d.getTime();            }        });  Handling Nested Form Case:          The above code will work if you have only one form. But this is not the case always.You may have a form control which wraps all the controls and you do not want to submit the whole form, just for getting a preview effect.           In this case you need to create a dynamic form control using JavaScript, and then add file upload control to this form and submit the form asynchronously  function ChangeImage(fileId,imageId)         {            var myform=document.createElement("form");                    myform.action="NerdDinner/ImagePreview/AjaxSubmit";            myform.enctype="multipart/form-data";            myform.method="post";            var imageLoad=document.getElementById(fileId).cloneNode(true);            myform.appendChild(imageLoad);            document.body.appendChild(myform);            $(myform).ajaxSubmit({success: function(responseText)                {                                    var contentType=responseText.substring(0,responseText.indexOf(';'));                    var contentLength=responseText.substring(responseText.indexOf(';')+1);                    var d=new Date();                    $(imageId)[0].src="http://weblogs.asp.net/MoneypingAPP/ImagePreview/ImageLoad?a="+d.getTime();                    document.body.removeChild(myform);                }            });        }            You also need append the child in order to send request and remove them after receiving response.

    Read the article

  • Generalized Ajax function [migrated]

    - by TecBrat
    Not sure if this question will be considered "off topic". If it is, I'll remove it, but: I hadn't see this yet so I wrote it and would like to know if this is a good approach to it. Would anyone care to offer improvements to it, or point me to an example of where someone else has already written it better? function clwAjaxCall(path,method,data,asynch) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if(asynch) { xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { //alert(xmlhttp.responseText); //var newaction=xmlhttp.responseText; //alert('Action becomes '+newaction); return xmlhttp.responseText; } } } if(method=='GET'){path=path+"/?"+data;} xmlhttp.open(method,path,asynch); if(method=='GET'){xmlhttp.send();}else{xmlhttp.send(data);} if (!asynch){return xmlhttp.responseText;} } I then called it like Just Testing <script type="text/javascript" src="/mypath/js/clwAjaxCall.js"></script> <script type="text/javascript"> document.write("<br>More Testing"); document.write(clwAjaxCall("http://www.mysite.com",'GET',"var=val",false)); </script>

    Read the article

  • Re-binding an ajaxForm after content re-loads with ajax (jQuery 1.4.2)

    - by Cristian
    I'm trying to figure out why this is a problem when using jQuery 1.4.2 and not 1.3.2. This is my function: function prepare_logo_upload() { $("#logo-upload-form").ajaxForm({ //alert(responseText); success: function(responseText) { //alert(responseText); $('#profile .wrapper').html(responseText); prepare_logo_upload(); } }); } Every other live event works but can't use the .live() method because ajaxForm is a plugin. I have noticed this also for other types of binding (clicks) using the old form (re-binding after callback) Can you tell me if it is a way of solving this? This is a similar question, but due to my newbie reputation here, can't comment or ask a question there, so I'll ask a new one here. - http://stackoverflow.com/questions/2208880/jquery-bind-ajaxform-to-a-form-on-a-page-loaded-via-load Thank you!

    Read the article

  • getting web page data as json object?

    - by encryptor
    I have a url, the data of which page i need as a json object. I ve tried xmlhttprequest and ajaxobject both but doesnt work. It doesnt even give a responseText when I give it as an alert Ill post both the code snippets here. url = http://mydomain.com:port/a/b/c AJAX : var ajaxRequest = new ajaxObject(URL); ajaxRequest.callback = function (responseText,responseStatus) { alert(responseStatus); JSONData = responseText.parseJSON(); processData(JSONData); } USING xmlhttprequest: var client = new XMLHttpRequest(); client.open('GET',URL,true ); data = JSON.parse(client.responseText); alert(data.links.length); can someone please help me out with this. I understand cross scripting may be an issue, but how to come over it? and shouldn't then too it should give the alerts as zero or null

    Read the article

  • How to display conformation text using jquery

    - by kumar
    I have showresponse funtion somehting like this.. function showResponse(responseText, statusText, xhr, $form) { if (responseText[0].substring(0, 16) != "System.Exception") { $('#error-msg-ID').html('<strong>Update successful.</strong>'); } else { $('#error-msg-ID').html('<strong>Update failed.</strong> ' + responseText[0].substring(0, 48)); } $('#error-msg-ID').removeClass('hide'); $('#gui-stat-').html(responseText[1]); } $('#exc-').ajaxForm({ target: '#error-msg-ID', beforeSubmit: validate_excpt, success: showResponse, dataType: 'json' }); Div tag is.. <div id="#error-msg-ID"> </div> After update successfull I am not able to show Updatesuccessful mesage on divtag? do i am missing something?

    Read the article

  • How to use $.get data to replace certain elements in a webpage?

    - by Jack Ha
    I'm using jQuery 1.4.2 to navigate smoothly between similar webpages (in ff3). When clicking on a link, a javascript script should load the new html, filter out the right elements and replace them on the current page. It looks like the $(htmlcode) does not do the thing I expected. The actions below work when loading the page directly, but when using the $.get I have the following problems: the find function seems only to look inside a div element called id="page", which is inside the body element one of the elements has <script>...</script>, but the <script>...</script> is not present in the DOM of $(htmlcode). Anybody knows how to solve this? $.get( url, function(responseText, textStatus, xmlHttpRequest) { alert($(responseText).find("#header")); // works, #header is inside div#page alert($(responseText).find("#header").html()); // displays content, but WITHOUT the <script>...</script> alert($(responseText).find("title")); // does not work, title is outside div#page } );

    Read the article

  • ajaxSubmit options success & error functions aren't fired

    - by Thommy Tomka
    jQuery 1.7.2 jQuery Validate 1.1.0 jQuery Form 3.18 Wordpress 3.4.2 I am trying to code a contact/ mail form in above environment/ with above jQuery libs. Now I am having a problem with the jQuery Form JS: I have taken the original code from the developers page for ajaxSubmit and only altered the target option to an ID which exists in my HTML source and replaced $ with jQuery in function showRequest. The problem is, that the function namend after success: does not fire. I tried the same with error: and again nothing fired. Only complete: did and the function I placed there alerted the responseText from the receiving script. Does anyone has an idea whats going wrong? Thanks in advance! Thomas jQuery(document).ready(function() { var options = { target: '#mail-status', // target element(s) to be updated with server response beforeSubmit: showRequest, // pre-submit callback success: showResponse, // post-submit callback // other available options: //url: url // override for form's 'action' attribute //type: type // 'get' or 'post', override for form's 'method' attribute //dataType: null // 'xml', 'script', or 'json' (expected server response type) //clearForm: true // clear all form fields after successful submit //resetForm: true // reset the form after successful submit // $.ajax options can be used here too, for example: //timeout: 3000 }; jQuery("#mailform").validate( { submitHandler: function(form) { jQuery(form).ajaxSubmit(options); }, errorPlacement: function(error, element) { }, rules: { author: { minlength: 2, required: true }, email: { required: true, email: true }, comment: { minlength: 2, required: true } }, highlight: function(element) { jQuery(element).addClass("e"); jQuery(element.form).find("label[for=" + element.id + "]").addClass("e"); }, unhighlight: function(element) { jQuery(element).removeClass("e"); jQuery(element.form).find("label[for=" + element.id + "]").removeClass("e"); } }); }); // pre-submit callback function showRequest(formData, jqForm, options) { // formData is an array; here we use $.param to convert it to a string to display it // but the form plugin does this for you automatically when it submits the data var queryString = jQuery.param(formData); // jqForm is a jQuery object encapsulating the form element. To access the // DOM element for the form do this: // var formElement = jqForm[0]; alert('About to submit: \n\n' + queryString); // here we could return false to prevent the form from being submitted; // returning anything other than false will allow the form submit to continue return true; } // post-submit callback function showResponse(responseText, statusText, xhr, $form) { // for normal html responses, the first argument to the success callback // is the XMLHttpRequest object's responseText property // if the ajaxSubmit method was passed an Options Object with the dataType // property set to 'xml' then the first argument to the success callback // is the XMLHttpRequest object's responseXML property // if the ajaxSubmit method was passed an Options Object with the dataType // property set to 'json' then the first argument to the success callback // is the json data object returned by the server alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + '\n\nThe output div should have already been updated with the responseText.'); }

    Read the article

  • Can't access Elements previously created by innerHTML with Javascript/Prototype

    - by Joe Hopfgartner
    I am setting the innerHTML variable of a div with contents from an ajax request: new Ajax.Request('/search/ajax/allakas/?ext_id='+extid, { method:'get', onSuccess: function(transport){ var response = transport.responseText || "no response text"; $('admincovers_content').innerHTML=response; }, onFailure: function(){ alert('Something went wrong...') } }); The response text cotains a form: <form id="akas-admin" method="post" action="/search/ajax/modifyakas/"> <input type="text" name="formfield" value="i am a form field"/> </form> Then I call a functiont that should submit that form: $('akas-admin').request({ onComplete: function(transport){ //alert('Form data saved! '+transport.responseText) $('admincovers_content').innerHTML=transport.responseText; } }); The problem is $('akas-admin) returns null , I tried to put the form with this id in the original document, which works. Question: Can I somehow "revalidate" the dom or access elements that have been inserted with innerHTML? Edit Info: document.getElementById("akas-admin").submit() works just fine, problem is i don't want to reload the whole page but post the form over ajax and get the response text in a callback function. Edit: Based on the answers provided, i replaced my function that does the request with the following observer: Event.observe(document.body, 'click', function(event) { var e = Event.element(event); if ('aka-savelink' == e.identify()) { alert('savelink clicked!'); if (el = e.findElement('#akas-admin')) { alert('found form to submit it has id: '+el.identify()); el.request({ onComplete: function(transport){ alert('Form data saved! '+transport.responseText) $('admincovers_content').innerHTML=transport.responseText; } }); } } }); problem is that i get as far as alert('savelink clicked!'); . findelement doesnt return the form. i tried to place the save link above and under the form. both doesnt work. i also think this approach is a bit clumsy and i am doing it wrong. could anyone point me in the right direction?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >