jQuery

17K

Solutions

5K

Contributors

jQuery (Core) is a cross-browser JavaScript library that provides abstractions for common client-side tasks such as Document Object Model (DOM) traversal, DOM manipulation, event handling, animation and Ajax. jQuery also provides a platform to create plugins that extend jQuery's capabilities beyond those already provided by the library.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hello ,
 I TEST it with WEB API using POSTMAN it give DATA as empty : Please suggest.

API URL:
http://localhost/school/Student/getStudentList

Result
{
    "Message": "Data Received successfully",
    "Status": true,
    "Data": [ ]
}

Open in new window



Below is the code pattern i am trying :

Models
public class Student
{
    public int StudentId { get; set; }
    public string ClassName { get; set; }
    public int LocationId { get; set; }
}

public class ResponseModel
{
    public string Message { set; get; }
    public bool Status { set; get; }
    public object Data { set; get; }
}

Open in new window


Service Method
public ResponseModel LoadStudents (SqlCommand comm)
{
    ResponseModel _objResponseModel = new ResponseModel ();
    List<Student> students = new List<Student> ();
    Student rls = new Student ();
    comm.CommandText = "Select StudentId,ClassName,LocationId from Students";
    SqlDataReader dr = comm.ExecuteReader ();

    while (dr.Read ())
    {
        rls.StudentId = dr.GetInt32 (0);
        rls.ClassName = dr.GetString (1);
        rls.LocationId = dr.GetInt32 (2);

        students.Add (rls);
    }

    dr.Close ();

    _objResponseModel.Data = students;
    _objResponseModel.Status = true;
    _objResponseModel.Message = "Data Received successfully";

    return _objResponseModel;
}

Open in new window


Action
[Route ("school/Student/getStudentList")]
[HttpGet]
public HttpResponseMessage GetStudentList ()
{
    UserRectification rtg = new UserRectification ();
    ResponseModel _objResponseModel = new ResponseModel ();
    HttpResponseMessage msg;

    try
    {
        _objResponseModel = LoadStudents (comm);
        msg = Request.CreateResponse (HttpStatusCode.OK, _objResponseModel);
    }
    catch (InvalidOperationException ioe)
    {
        msg = Request.CreateResponse (HttpStatusCode.BadRequest, ioe.Message);
    }
    catch (Exception ex)
    {
        msg = Request.CreateResponse (HttpStatusCode.InternalServerError, ex.Message);
    }
    finally
    {

    }

    return msg;
}

Open in new window

0
I am developing my first application with Apache Cordova and I need some assistanstance with the Open Street Map object. I am sending a request to the Open Street Map to get Lat/Lng of a location. I chose Manchester UK and I received the following JSON back:

ManchesterUK.PNG
In order to do this, I set to share a taxi (it's a taxi sharing app) first and then I click on Update Map.
This is the code for UpdateMap:

snipping.PNG
     function updateMap(address){
        var onSuccess = function(position) {
          var div = document.getElementById("map_canvas");
          div.width = window.innerWidth - 20;
          div.height = window.innerHeight * 0.8 - 40;
          // change the zoomin level
          map.setZoom(15);
          if (address != undefined) {
            // TODO 2(a) FR2.2
            var endPoint = "https://nominatim.openstreetmap.org/search/" + address + "?format=json&countrycode=gb"
            $.get(endPoint,function(e) {[embed=file 1418190][embed=file 1418191][embed=file 1418192]
              var location = e;
              map.setCenter({
                lng: location.lng,
                lat: location.lat
              });
            })


          } else {
            map.setCenter({
              lng: position.coords.longitude,
              lat: position.coords.latitude
            });
          }
        };
        var onError = function(error) {
          alert(
            "code: " + error.code + "\n" + "message:

Open in new window

0
Hello!

I'm having a problem with this page: https://www.benknier.com/skills.html 

The page used to load and display properly, but within the last couple of weeks it has stopped working altogether. It seems to flash the content and then disappear. All of the other pages on the site work properly and I haven't been able to pinpoint the issue by looking at what's in the console. I've attached a copy of the source code to this post.skills.html

Any help you can give me in getting this working properly will be greatly appreciated!

Thank you in advance.
0
I'm a non-programmer (i.e., designer) using JQuery Mobile 1.2.1 (I know this is old, in the process of updating). When a visitor arrives at a particular static page via an outside link that includes a #hash at the end of the URL (i.e., "my-site.com/mypage.html#target", #target being a section inside a collapsible), I need a collapsible on that page to expand, then I need the page to scroll smoothly to the target of the hash.

At the moment, this is a very specific use case, where I know the exact section and the target I want to scroll to, but it would be nice if this code could be reusable for any external link coming to a page where I would like to scroll to any target that's inside any collapsible. At this point, I'd settle for anything that works, as this is a somewhat urgent request.

I'm able to accomplish this sort of thing when just navigating to targets within a page via click, but when arriving from outside the page/site via a hash link URL, the results are very random and somewhat unpredictable. The collapsible opens, and then either the page scrolls to the target then immediately resets to view to the top of the page, or the scroll lands off target by varying margins. Kinda maddening.

This is where I've arrived most recently before throwing up my hands and running here.

$(window).bind("load", function() {
    	var hashName = window.location.hash;
//because I know the specific hash, I put it in an if statement to keep it from possibly interfering 

Open in new window

0
I use js datatable and everything is working. Now I want to use ajax loading because my report will take some time to generate the report.
I tried to use processing in the js datatable but it is not working to me. Hope you can show me how it works.


 $('#data-table').DataTable({
                            "dom": 'Bfrtip',
                            "buttons": ['copyHtml5', 'excelHtml5', 'pdfHtml5', 'csvHtml5'],
                            "paging": true,
                            "ordering": true,
                            "info": true,
                            "bDeferRender": true,
                            "pageLength": 100,
                            "scrollY": 600,
                            "bSort": true,
                            "stateSave": true,
                            "fixedHeader": true,
                            "responsive": true,
                            "bDestroy": true
                        });

Open in new window

1
<p>	bullet point bug test</p><ul><li>	</li><li>		1	</li><li>		2	</li><li>		3	</li><li>		4	</li><li>		5</li></ul>

Open in new window



so i have a string from CKEDTIOR ,

it keeps adding in blank bullet points,

is their a way to remove the <li> </li> if it has no value inside it ?

for example keep the li with 1 , 2 ,3 but remove the first one which is blank ?
0
I'm making a semi-simple chat client.

I'm using CryptoJS to encrypt a string, then JQuery to send that string to a web handler, and storing that in SQL

... then attempting to retrieve the string, and decrypt it.

It works...sometimes, not all the time.  I assumed it has something to do with string encoding and escaping URI.. or I'm doing something wrong in the encrypt() and decrypt() methods.  Now I seem to be going backward in success rate.

I can't figure out why it wouldn't just work all the time, or not at all.
When I use alert(encryptedmessage), and alert(messagetodecrypt) ....both strings appear to match perfectly, which adds to the mystery.

Any ideas??


<!DOCTYPE html>
<html>
<head>
    <title></title>
	<meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />

    <script type="text/javascript" src="/Scripts/jquery-min.1.9.0.js"></script>

    <script type="text/javascript" src="/Scripts/aes.js"></script>


    <script>
        var channelid = "nullchat";
        var key = "public";
        var keySize = 256;
        var ivSize = 128;
        var iterations = 100;

        
        window.onunload = SetInt();

        function SetInt() {
            window.setInterval(GetID, 2500);
        };

        function channelset(val) {
            channelid = val;
        };

        function keyset(val) {
            key = val;
        };

        function post(val) {

      

Open in new window

0
The following item is not working and not sure why.

1. I see the result set / value, but the first row shown 'No data available in table'
2. when I click on the <th></th> and try to sort, all data is disappeared.
3. when the table is loading (it may take 10 seconds just because of the large report),
where i can add the like ajax loading animated images? or how should I handle it?
4. The paging is not working. it shows every rows (10,000).
5. when I keep refresh the webpage, it keeps adding up the rows every 10,000

Thanks




 
 <table id="data-table" class="table table-bordered" width="100%">
                    <thead>
                        <tr>
                            <th>Row Count</th>
                            <th>id</th>
                        </tr>
                    </thead>
                </table>

 function test2() {
        $(document).ready(function () {
            $('#data-table').DataTable({
                "paging": true,
                "ordering": true,
                "info": false,
                "bProcessing": true,
                "bDeferRender": true,
                "pageLength": 50,
                "scrollY": 600,
                "bSort": true,
                "stateSave": true
            });
            var tr;
            var data = new Array();
            var x=0;
            $.ajax({
                url: "/Accounting/TestMe",
                type: "Post",
                data: JSON.stringify(data),
              

Open in new window

0
hi experts. can you show me super simple demo with mvc web api (without entity framework)  that using js datatable?
I have some troubles on the ajax part. The web api is showing data in the browser but I have some trouble to call web api in ajax jquery.
0
Joomla: "UI should be replacement of Joomla core, loaded at component or template level"  Can someone explain to me the best way to go about replacing the Joomla core jQuery UI with another UI?
0
I have simple mvc Ajax call using JavaScript. and after the call is successfully completed the job. how can I get the data from the server side without refresh?

the Ajax call is to update some records only.

another question is how to keep the vertical position after the call. for example, some of the webpage will have to scroll down to see information and I want to keep scroll down position.
0
https://developers.google.com/calendar/quickstart/dotnet
I hope to get list of music concert event based on the zip codes
and I used above google api.

can you guide me how to filter just music event and zip?

I use c#
0
I would normally just echo out the search results using php when doing an Ajax search but this time I am trying to use a json response instead. For seem reason I am getting duplicate results like:

result 1
result 2
result 1
result 2

when it should just be

result 1
result 2

DB Query:

    public static function searchContacts($searchText)
    {
        $searchTerm = "%{$searchText}%";
        
        $db = static::getDB();
        $stmt = $db->prepare("SELECT `id`, `first_name` FROM `contacts` WHERE `first_name` LIKE ?");
        $stmt->execute([$searchTerm]);
        return $stmt->fetchAll(PDO::FETCH_CLASS, get_called_class());
    }

Open in new window


Controller:

    public function search()
    {
        if ($_SERVER['REQUEST_METHOD'] === 'POST') {
            
            $response = [];
            
            $searchText = trim($_POST['searchText']);
            
            $searchResults = Contact::searchContacts($searchText);
            $response['results'] = $searchResults;
            
            echo json_encode($response);
            
        }
    }

Open in new window


jQuery/Ajax

    $('#search').keyup(function () {
        var searchText = $('#search').val();
        if (searchText.length > 3) {
            $.ajax({
                    url: url + '/Contacts/search',
                    type: 'POST',
                    dataType: 'json',
                    data: {
                        searchText: searchText
                    }
                })

                .done(function (data) {

                    $.each(data.results, function (index, item) {
                        $('.search-results').append("<a href=' " + url + '/contacts/' + item.id + " '>" + item.first_name + "</a>" + "<br>").show();
                    });
                })

                .fail(function (jqXHR, textStatus, errorThrown) {
                    console.log(textStatus + ': ' + errorThrown);
                    console.warn(jqXHR.responseText);
                });
        } else {
            $('.search-results').hide();
        }
    });

Open in new window

0
Here's my code:

<div id="helper" style="display:none;"></div>
<input id="ord_reviewOrder_submit" type="button" class="btn_base btn_green_60" value="Submit" onclick="$('#ord_reviewOrderError').slideUp().html('');
       if($('#ord_deliveryMethod').val().length == 0 || $('#ord_deliveryCost').val().length == 0)
       var amount = $('#helper').val();
       $('#ord_reviewOrderError').append('A delivery method must be selected to process the order.<br/>');
       [b]$('#ord_reviewOrderError').append('$('#helper).val()');[/b]

Open in new window


What you're looking at is a part of a page that I'm being asked to troubleshoot.

The solution I'm trying to engineer will be looking for the value the API is going to be putting in the "helper" div.

Ultimately, I want to be able to evaluate that value, but for now I'm just trying to reproduce it and I can't get it to show up in the line that I have in bold.

There's no error, but there's no value either.

When I look at the source code, I can see this:

[code]<div id="helper">1000</div>

But I won't see "1000" in the "ord_reviewOrderError" div which is located toward the bottom of the page.

No error, but no value.

What am I missing?
0
I am hoping this is an easy solution that I am just overcomplicating.

1) I have JSON data stored in a hidden div
2) I want to parse that JSON data for a particular record and get a specific value (code) from the record.
3) I want to use a URL parameter called id to filter for that specific JSON record and get the code from the data.
4) below is the code I started putting together but I can't see to successfully figure out how the parse the JSON data for the record I need.
 
//URL Parametercode
$(document).ready(function() {
if (getParameterByName('id') != '') {
 
//use ID To get course code
var courseid = getParameterByName('id');
console.log(courseid);

var courseJSONDdata = $("#coursedata").text();
console.log('THIS IS A TEST' + $("#coursedata").text());

//filter by Paramter ID
function filter(courseJSONdata, courseid) {
           var result = [];
           if (courseid)
               result = courseJSONdata.filter(function (item) { return item.dataid == courseid });
           return result;
       }
       
console.log('RESULT TEST ' + result);

///Load the Data for the Course after Parameter
   LoadQuestions(coursecode, $("#answers").text());
   LoadData(coursecode, $("#coursedata").text());
   }
   }
);

function getParameterByName(name) {
  var res = new RegExp(
      // Parameter names always start after a ? or &.
      '[\?&]' +

      // Make sure any [ or ] are escaped in the name.
      name.replace(/\[/g, '\\\[').replace(/\]/g, '\\\]') +

   

Open in new window

0
I am dealing with an SAAS application that generates html pages that use css

Only some of this css is open for "configuration" (i.e. that I can change)

I have a need to hide a delete button - but I  am NOT a css guru

I want to hide/disable ONLY THIS button:
<button xmlns:urlencoder="java:java.net.URLEncoder" 
xmlns:stringext="java:com.niku.union.xsl.StringExt" 
type="button" onclick="submitForm('page_XXXList','odf.deleteObjectInstancesConfirm','odf_sub_object_code=XXX','odf_is_sub_object=true','odf_cncrt_parent_id=5000002','odf_parent_id=5000002','parentObjectCode=ZZZ','ui.page.space=odf.ZZZList','partition_code=NIKU.ROOT');" 
style="  " 
class="ppm_button ">
<img src="ui/uitk/images/s.gif" class="caui-ndeCheckmark" alt="Delete" title="Delete" border="0" align="absmiddle">
&nbsp;Delete
</button>

Open in new window

NOTE this string ,'odf_sub_object_code=XXX'  makes this button unique i.e. the odf_sub_object_code value XXX is relevant (I think)

How might hiding this button be possible?

ps. the CSS is large, if you need snippets from it please let me know what bits are needed.
0
Can you reference a asp tag that is passed in variable.  I have a table  that contains rows which
contain asp id's example aspTagName = txtFirstName,  fielRequired = false

I want to look at the column fieldRequired and based on value of false
remove the attribute required from the asp page using the value of
the aspTagName(txtFirstName)

Please advise.

Thanks in advance
0
Hi, on https://magickitchen.com, there's a console error.

jquery.min.js:4 Uncaught TypeError: a.indexOf is not a function
    at r.fn.init.r.fn.load (jquery.min.js:4)
    at plugins.min.js:2
    at plugins.min.js:2

All I can find is that it could be a problem with the version of jquery (we are using https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js), or that there's some code using load, unload or error. I can't find any code doing that.

Can anyone tell me where I can fix this error? Thanks!
0
this is a follow on to the question at
https://www.experts-exchange.com/questions/29138630/JQuery-If-Test-Not-Working.html?headerLink=workspace_open_questions

Open in new window


I need the cookie to be deleted when they close the browser or submit the order.   This is the code I have to delete the cookie but it isn't going away for either reason.

jQuery('#cook').click(function(e) {
		e.preventDefault();
		document.cookie = "wantmembership=1; path=/";
document.cookie = 'wantmembership=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
          jQuery(this).css('background-color','green');
              jQuery(this).text("I Now Have A Membership!");
			});

Open in new window

0
Hi experts,

I have a question regard to sending data with PHP curl POST, GET vs jquery or javascript ajax request with post and get. Are there any differences in using one over the other as in securely passing data between client and server? I see most examples were dealing with ajax request by sending data over to the server with either GET or POST and obtain data in json instead of using curl to perform this task.  Thanks!
0
I have a jQuery DataTable with columns added for filtering. I'm trying to figure out how to get the select drop-downs to update to match the visible rows whenever the table is filtered on some other row.
The DataTable is setup like this:
<table id="TrainingSchedule" style="width:95%" >   
    <thead>   
        <tr class="filterrow">
            <th><select class="filterSelect" id="filter_Day_0"></select></th>               
            <th><input class='filterInput' id="filter_Date_1" /></th> 
            <th><input class='filterInput' id="filter_StartTime_2" /></th> 
            <th><input class='filterInput' id="filter_EndTime_3"  /></th>  
            <th><input class='filterInput' id="filter_Title_4" /></th> 
            <th><select  class="filterSelect" id="filter_Location_5"></select</th>
            <th><input class='filterInput' id="filter_Room_6" /></th> 
            <th><input class='filterInput' id="filter_Course_7"   /></th>  
            <th><input class='filterInput' id="filter_CourseNumber_8"  /></th>  
            <th><input class='filterInput' id="filter_SectionNumber_9"  type="text" /></th>  
            <th><select class="filterSelect" id="filter_Instructor_10"></select></th>
            <th><select class="filterSelect"  id="filter_Type_11"></select></th>
            <th><select class="filterSelect" id="filter_Ignore_12"></select></th>             
            <th><input class='filterInput' id="filter_DateAdded_13"  /></th>  
        </tr>      
    

Open in new window

0
Screen-Shot-2019-03-22-at-15.18.32.png
so the image is my message editor which i am using ckeditor to create templates,

this text is wrapped in paragraph tags ,

the text within the curly brackets refers to a property,

so when you insert this template on a users profile those id within the curly brackets displayed their info so in this image first name and last name,

is their s way i can read these id within the curly brackets ? im using php
0
I am getting
IE11 throwing “SCRIPT1014: invalid character”  for the below line of code

`<div class="comment">
                <div class="${originClass}">
                    <p>${comment}</p>
                    <date><b>${sender}</b> ${date} <fromDB><divstyle= "visibility: hidden; width: 0px;">${fromDB}</div></fromDB></date>
                              
                </div>
            </div>`

looks like the issue is with "`". it works ok on chrome and firefox but IE seems to be having some issues with it.
0
Good Evening Everyone

I am trying to do a registration MODAL to post using php and get back a confirmation result, I have it working in the normal submission method POST using php, which passes the variables and reloads the page to registration.php after submission.

This is the MODAL below :
           <!--Body-->
                    <div class="modal-body">
                        <form method="POST" action="/registration.php">
                      <div class="md-form form-sm mb-5">
                        <i class="fas fa-user prefix" style="color: dodgerblue "></i>
                          <input class="form-control" id="fname" name="fname" type="text" placeholder="&nbsp First Name"><br>
                      </div>

                      <div class="md-form form-sm mb-5">
                        <i class="prefix"></i>
                          <input class="form-control" id="lname" name="lname" type="text"  placeholder="Last Name"><br>
                      </div>

                      <div class="md-form form-sm mb-4">
                        <i class="fas fa-address-book prefix"></i>
                          <input class="form-control" id="address" name="address" type="text"  placeholder="Address"><br>
                      </div>
                        <div class="container">
                        <div class="form-check-inline">
                            <label class="form-check-label">
                                <input type="radio" 

Open in new window

0
it's a bizarre problem the program screen starts shaking resizing slightly it's only happens when screen is shrink slightly
please advise what might be happening here
I have a clock that gets displayed in the lower right-hand corner although I had moved it to the center and it made no difference
I am using the sex State mounted to call the setinterval
function it works great until the screen is modified slightly and then it starts breathing as the right Edge moves to the left and to the right an animated fashion.
right now I'll entertain any possible solution it's weird
 
well I can't show the actualcode. I will try in and create a copy to recreate the problem.
set interval causes update of information that is then displayed
within mustaches. {{ datetimestring}}
it would almost seem like maybe it was due to variable fonts
but but then why is it triggered by resizing with screen eg shrinking the screen or adding a component div or span to screen ?

I will post an example of what I'm talking about when I get a chance
0

jQuery

17K

Solutions

5K

Contributors

jQuery (Core) is a cross-browser JavaScript library that provides abstractions for common client-side tasks such as Document Object Model (DOM) traversal, DOM manipulation, event handling, animation and Ajax. jQuery also provides a platform to create plugins that extend jQuery's capabilities beyond those already provided by the library.

Related Topics