Search Results

Search found 45 results on 2 pages for 'kwokwai'.

Page 2/2 | < Previous Page | 1 2 

  • Is this the only way to pass a parameter for Cakephp to work with JQuery Ajax

    - by kwokwai
    Hi all, I was doing some self-learning on how to pass data from JQuery Ajax to a particular URL in CakePHP: I have tested three sets of codes that the first one was working well, but the rest failed to work, which makes me so confused. Could some experts here tell why the second and the third sets of codes failed to pass any data? Set 1: <input type=text name="data[User][name]" id="data[User][name]" size="36" maxlength="36"/> var usr = $("#data\\[User\\]\\[name\\]").val(); $.post( "http://www.washington.byethost18.com/site1/toavail/"+usr, function(msg){alert(msg);} ); Set 2: <input type=text name="data[User][name]" id="data[User][name]" size="36" maxlength="36"/> var usr = $("#data\\[User\\]\\[name\\]").val(); $.post( "http://www.washington.byethost18.com/site1/toavail/", {queryString: ""+usr+""}, function(msg){alert(msg);} ); Set 3: <input type=text name="data[User][name]" id="data[User][name]" size="36" maxlength="36"/> var usr = $("#data\\[User\\]\\[name\\]").val(); $.post( "http://www.washington.byethost18.com/site1/toavail/", usr, function(msg){alert(msg);} );

    Read the article

  • JQuery Ajax returned blank data

    - by kwokwai
    Hi all, I am learning how to use JQuery to help check data availability. I have written a function in a Controller for checking data input, and the URL is like this: http://www.mywebsite.com/controllers/action/avariable but the returned data was blank. <Script language="javascript"> $(document).ready(function(){ $(document).change(function(){ var usr = $("#data\\[User\\]\\[name\\]").val(); $.post{"http://www.mywebsite.com/controllers/action/", usr, function(msg){alert(msg);} } }); }); </Script> <div id="username"> <input type=text name="data[User][name]" id="data[User][name]"> </div> Here is the code of the Action: function action($data=null){ $this->autoRender = false; $result2=$this->__avail($udata); if($result2==1) {return "OK";} else {return "NOT";} }

    Read the article

  • Can a program have a few IFs and only one Else structures?

    - by kwokwai
    Hi all, When I was doing some JQuery and PHP, I noticed the If-else patterns were treated differently and varied from one language to another. Say I got a simple input text field in a HTML and I was using some Ifs and Elses to check the value input into the text field. Text: <input type="text" name="testing"/> In JQuery, I got some codes as follows: if($("#testing").val()==1){ //do something } if($("#testing").val()=="add"){ //do something } else{ //do something } if($("#testing").val()=="hello"){ //do something } How come JQuery and PHP treated the Else statement differently? I mean in JQuery, the third If statement was still proceeded even if it had gone to the Else statement, but it stopped after the Else statement when I repeated the code in PHP script.

    Read the article

  • Load some data from database and hide it somewhere in a web page

    - by kwokwai
    Hi all, I am trying to load some data (which may be up to a few thousands words) from the database, and store the data somewhere in a html web page for comparing the data input by users. I am thinking to load the data to a Textarea under Div tag and hide the the data: <Div id="reference" style="Display:none;"> <textarea rows="2" cols="20" id="database"> html, htm, php, asp, jsp, aspx, ctp, thtml, xml, xsl... </textarea> </Div> <table border=0 width="100%"> <tr> <td>Username</td> <td> <div id="username"> <input type="text" name="data" id="data"> </div> </td> </tr> </table> <script> $(document).ready(function(){ //comparing the data loaded from database with the user's input if($("#data").val()==$("#database").val()) {alert("error");} }); </script> I am not sure if this is the best way to do it, so could you give me some advice and suggest your methods please.

    Read the article

  • Non-CDN hosted jQuery caused some strange behaviour

    - by kwokwai
    Hi all, I was using this JQuery in this download link, and included it in the head tag of a HTML web page: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> In a php web page, I got these few lines of codes: $.ajax({ url: 'http://mywebsite.com/site1/toavail/, type: "post", success: function(data) { // some more code here } }); When I tested the HTML page in IE 6, and 7, I saw the same warning message: "permission denied" When I tested it in Firefox 3, nothing was returned from the server web page. Later, I changed the JQuery source link to be: http://code.jquery.com/jquery-1.4.2.js I refreshed the web page, and I could saw the returned value then.

    Read the article

  • How to make sure the value is reset in foreach loop in PHP

    - by kwokwai
    Hi all, I was writing a simple PHP page and a few foreach loops were used. Here are the scripts: $arrs = array("a", "b", "c"); foreach ($arrs as $arr) { if(substr($arr,0,1)=="b") { echo "This is b"; } } // ends of first foreach loop and I didn't use ifelse here And when this foreach ends, I wrote another foreach loop in which all the values in the foreach loop was the same as previous foreach. foreach ($arrs as $arr) { if(substr($arr,0,1)=="c") { echo "This is c"; } } I am not sure if it is a good practice to have two foreach loops with same values and keys. Will the values get overwritten in the first foreach loop?

    Read the article

  • Is it good to use JQuery's validation plugin?

    - by kwokwai
    Hi all, I am learning JQuery, and I have checked out that JQUery has got a validation plugin. http://docs.jquery.com/Plugins/Validation#Validate_forms_like_you.27ve_never_been_validating_before.21 To use it, users have to include another script file in the Head tag in HTML. I am thinking if this will cause any code collisions to the codes in the validation plugin when more and more javascript files are included. Should I use JQuery to write myself new customed functions for checking data input from users or use the JQuery data validation plugin? Please advise.

    Read the article

  • non-CDN Hosted jQuery caused strange some behaviour

    - by kwokwai
    Hi all, I was using this JQuery in this download link, and included it in the head tag of a HTML web page: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> In a php web page, I got these few lines of codes: $.ajax({ url: 'http://mywebsite.com/site1/toavail/, type: "post", success: function(data) { // some more code here } }); When I tested the HTML page in IE 6, and 7, I saw the same warning message: "permission denied" When I tested it in Firefox 3, nothing was returned from the server web page. Later, I changed the JQuery source link to be: http://code.jquery.com/jquery-1.4.2.js then I refreshed the web page, and I could saw the returned value.

    Read the article

  • How to pass some data to JQuery AJAX in CAKEPHP

    - by kwokwai
    Hi all, I am learning how to use JQuery to help check data availability. To start with it, I wrote a few lines of codes using cakePHP. I have written a function in a Controller for checking data input, and the URL is like this: http://www.mywebsite.com/controllers/action/avariable I was trying to pass the value in a Input TextBox field using the JQuery Ajax to the URL above,but I don't know why it is not working in passing a variable to the Controller's action. Could you help me out please? <Script language="javascript"> //<!-- $(document).ready(function(){ $(document).change(function() { var usr = $("#data\\[User\\]\\[name\\]").val(); if(usr.length >= 3){ $("#username").append('<span><img align="absmiddle" src="loader.gif" />Checking</span>'); $.ajax({ type: "POST", url: "http://www.mywebsite.com/controllers/action/", data: usr, success: function(msg){ if(msg == 'OK') { $("#username").append('<span><img align="absmiddle" src="accepted.png"/></span>'); } else { $("#username").append('<span>'+msg+'</span>'); } } }); } else { $("#username").append('<span>The username should have at least 3 characters.</span>'); } }); }); //--> </Script> <form name="adduser" id="adduser" method="post" action="/controllers/action2"> <table border=0 width="100%"> <tr> <td>Username</td> <td> <div id="username"> <input type=text name="data[User][name]" id="data[User][name]"> </div> </td> </tr> <tr> <td> <input type="submit" value="Send"> </td> </tr> </table> </form>

    Read the article

  • Cake returned the time consumed in data lookup in JQuery Alert Box

    - by kwokwai
    Hi all, When I was doing some self-learning on JQuery Ajax in Cakephp, I found out some strange behaviour in the JQuery Alert Box. Here are a few lines of code of the JQuery Ajax I used: $(document).ready(function(){ $(document).change(function(){ var usr = $("#data\\[User\\]\\[name\\]").val(); $.post{"http://www.mywebsite.com/controllers/action/", usr, function(msg){alert(msg);} } }); }); The Alert box shows me a message returned from the Action: Helloworld <!--0.656s--> I am not sure why the number of time consumption was displayed in the Alert box, since it was not in my code as follows: function action($data=null){ $this->autoRender = false; $result2=$this->__avail($data); if($result2==1) {return "OK";} else {return "NOT";} } CakePHP rteurned some extra information in the Alert box. Later I altered a single line of code and tried out this instead, and the time consumption was not displayed on screen then: $(document).ready(function(){ $(document).change(function(){ var usr = $("#data\\[User\\]\\[name\\]").val(); $.post{"http://www.mywebsite.com/controllers/action/", usr, function(msg){$("#username").append('<span>'+msg+</span'>);} } }); });

    Read the article

  • [CakePHP] What is the best way to access another Model in a Controller?

    - by kwokwai
    Hi all, Say I got two Controllers like this Table1sController, and Table2sController. with corresponding Models: Table1sModel, Table2sModel In the Table1sController, I got this: $this-Table1sModel-action(); Say I want to access some data in Table2sModel How is it possible to do something like this in Table1sController I have tried this in Table1sController: $this-Table2sModel-action(); But I received an error message like this: Undefined property: Table1sController::$Table2sModel

    Read the article

  • removeClass doesn't work on the second DIV tag

    - by kwokwai
    Hi all, I am learning JQuery and writing a simple data validation for the two fields in a HTML form: <FORM name="addpost" id="addpost" method="post" action="/add"> <TABLE BORDER=0 width="100%"> <TR> <TD>Topic</TD> <TD> <DIV ID="topic"> <INPUT type=text name="topic" id="topic" size="72" maxlength="108"/> </DIV> </TD> </TR> <TR> <TD>Comments</TD> <TD> <DIV ID="topiccontent"> <TEXTAREA rows="12" cols="48" name="content" ID="content"> </TEXTAREA> </DIV> </TD> </TR> <TR> <TD> <INPUT type="submit" value="Send"> </TD> </TR> </TABLE> </FORM> Here is the JQuery script for checking the data input from the form above: $('#addpost').submit(function(){ if($('#topic').val()==""){ $('#topic').addClass('hierror'); return false;} else{$('#topic').removeClass('hierror');} if($('#topiccontent').val()==""){ $('#topiccontent').addClass('hierror'); return false;} else{$('#topiccontent').removeClass('hierror');} }); Here is the CSS for the hierror class: .hierror{border-style:solid; border-width:12px; border-color:#FF0000;} ('#topic').removeClass('hierror') works but ('#topiccontent').removeClass('hierror') doesn't. Could you help me please?

    Read the article

  • A simple message board with WYSIWYP

    - by kwokwai
    Hi all, I am making a simple message board with some WYSIWYP function using cakePhp 1.26. I have googled for some hints and finally reached this URL: http://bakery.cakephp.org/tags/view/wysiwyg But I am not sure which one is the best out there.

    Read the article

  • Fields in CakePHP could not be referred by JQuery

    - by kwokwai
    Hi all, I have got a simple HTMl form with one field as follows: <input type="text" name="data['User']['user_id']" id="data['User']['user_id']" value="1"> $(document).ready(function(){ $("#data['User']['user_id']").mouseover(function(){ alert("hello"); }); }); The code couldn't work, I think it may be the name of the Input text field that caused the problem, but I don't know how to alter it because this is the naming convention in CakePHP.

    Read the article

  • beforeSave() returned some error

    - by kwokwai
    Hi all, I got a simple input text field in a HTML form: <input type="text" name="data[User][pswd]" id="data[User][pswd]"> The scripts for the Controller's action that captured the data is as follows: function register(){ $temp = $this->data; if(strlen($temp['User']['pswd'])>6) { if ($this->User->save($this->data)) { $this->Session->setFlash('Data was Saved'); } } } // this script works And in the Model controller, I got these lines of codes: function beforeSave() { $raw = $this->data; if(strlen($raw['User']['pswd'])>6){ md5($raw['User']['pswd']); } return true; } // this script failed to work The data was stored into the Database successfully but it was not undergone any MD5 encryption. I think that there must be some errors in the Model's script because I saw some errors flashed after the data was saved, but the screen that showed the errors immediately refreshed in a second after the data was saved successfully and I couldn't see the detail of the errors that caused the problem. Could you help me out please?

    Read the article

  • Empty data was able to be stored to the Database in CakePHP even if "Not Null" had been specified.

    - by kwokwai
    Hi all, I was doing some self learning on CakePHP 1.26 with Mysql 5. I got a simple table with only one field and had applied "Not Null" to this field. This field in the table was corresponding to a Input text box in a HTML form. I tried not to enter anything into the Input text field, and then I saw that empty data was able to be stored into the Table even if "Not Null" had been applied to this field. I am confused of this result. Could you help me please?

    Read the article

  • Dont know how to select a few records from a table as utf8

    - by kwokwai
    Hi all, I don't have phpMyAdmin installed in my web site. Sometimes I was doing some select SQL command at the backend, but when I typed in this command to show all records from table Users: select * from Users; The records were printed as ???? | ??? ??? ??? |. I don't want to make any permanent changes to the charset in the database, so, how is it possible to temporarily displayed a few records as utf8 when needed?

    Read the article

  • [Cakephp] How to use Read()

    - by kwokwai
    Hi all, In a Controller, I got this: $this->Site1->post_id=$id; $this->set('posts', $this->Site1->read()); And when I replaced it by this line of code: $this-set('posts', $this-Site1-read('post_id', $id)); But the returned result is totally different. Is there any difference between them? Is it possible to make this two lines of code neat by re-writing it into one line of code? $this->Site1->post_id=$id; $this->set('posts', $this->Site1->read());

    Read the article

< Previous Page | 1 2