Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ajax and back end code #77

Closed
TEStaff opened this issue Nov 22, 2021 · 8 comments
Closed

Ajax and back end code #77

TEStaff opened this issue Nov 22, 2021 · 8 comments

Comments

@TEStaff
Copy link

TEStaff commented Nov 22, 2021

I am using c# to return this json from a database. The dropdown list is not triggering but the Json is returning

["adoptdontshop","America","Approvalratings","Atlanta","Based","Basedmemes","bitcoin",
"blackcat","blackcatclub","blackcatlove","blackcatlover","blackcats","blackcatsmatter",
"striketober","TheGreatResignation","TopNews","TPUSA","TPUSALive","transparency","trilliondollarbill",
"uni","USA","VaccineNews","WhiteHouse","Winsomesears"]

@amsify42
Copy link
Owner

Is your response in this format

{
	"suggestions": [
		{
			"tag": "Black",
			"value": 1,
			"background":"black",
			"color":"white"
		},
		{
			"tag": "White",
			"value": 2,
			"background":"white",
			"color":"black"
		}
	]
}

and are you returning json header properly?

@TEStaff
Copy link
Author

TEStaff commented Nov 22, 2021

I am now returning this, but still not able to see it in the dropdown:

{
"suggestions": [
{
"tag": "bitcoin",
"value": 33
},
{
"tag": "trilliondollarbill",
"value": 78
}
]
}

@amsify42
Copy link
Owner

I know very little about C#. This might help you figure out whether you are spending a proper json response or not.
https://stackoverflow.com/a/2423155

@TEStaff
Copy link
Author

TEStaff commented Nov 23, 2021

I am returning the correct Json. I am placing a copy of the returned data in a div below for testing. This is my jquery code below. I am pulling data from a sql server and the result is not attaching to the dropdown:

$('input[name="toAjax"]').amsifySuggestags({
            suggestionsAction: {
                url: "/ajaxmethods/SearchHashtags/",
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("XSRF-TOKEN",
                        $('input:hidden[name="__RequestVerificationToken"]').val());                },
                type: 'GET',
                whiteList: true,
                dataType: "json",
                success: function (data) {
                    if (data != null) {
                     $("#MyFavoriteHashtags").append(data);
                    }
                },              
                error: function (response) {
                  //$("#MyFavoriteHashtags").html(response.responseText);
                },
                complete: function (data) {
                    console.info('complete');
                }    
            }
        });

GIF 11-23-2021 1-36-23 PM

@amsify42
Copy link
Owner

Can you please inspect your html elements in some browser and see whether any stylings are overriding and hiding those suggestions list.

@TEStaff
Copy link
Author

TEStaff commented Nov 24, 2021

I am not seeing any styling conflicts, but maybe you can identify the issue here. (still under development and will need a quick account since this is secured):

https://www.voicer.net/userpages/crud/ajaxpage

Your component works very well with the exception of this ajax/database call

@mitesh24shah24
Copy link

i am facing same issue as ajax not working. for me , its not initiating ajax call in network.
is there any minimum jquery and bootstrap version requirement ?

below is my code snippet

$('input[name="toAjax"]').amsifySuggestags({
tagLimit: 3,
minChars: 1,
type: "GET",
url: site_url+'buy/testhello',
whiteList: true,
dataType: "json",
beforeSend : function() {
console.info('beforeSend');
},
success: function(data) {

                                console.info('success');console.log(data);
                        },
                        error: function() {
                                console.info('error');
                        },
                        complete: function(data) {
                                console.info('complete');
                        }
                });

@amsify42
Copy link
Owner

amsify42 commented Dec 8, 2021

@mitesh24shah24
You need to pass those ajax settings under suggestionAction object. Please check here
https://github.com/amsify42/jquery.amsify.suggestags#suggestions-through-ajax

@amsify42 amsify42 closed this as completed Apr 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants